#include <iostream>
#include <cstring>
using namespace std;

int pos[1100][1100];

int main()
{
	int n;
	while (cin >> n)
	{
		int q[1100],minnum[1100];
		int peri=1;
		int minquentity[1100];
		int temp=0;
		int countnum=0;
		memset(minnum,0x7f,sizeof(minnum));
		memset(minquentity,0,sizeof(minquentity));
		for (int i=1;i!=n+1;++i)
		{
			cin >> q[i];
		}
		for (peri=1;temp!=n;++peri)
		{
			for (int i=1;i!=n+1-temp;++i)
			{
				minnum[peri]=min(minnum[peri],q[temp+i]);
			}
			for (int i=1,a=1;i!=n+1-temp;++i) // calculate the quantities of minnum
			{
				if (minnum[peri]==q[temp+i])
				{
					pos[peri][a]=i+temp;
					++a;
					++minquentity[peri];
				} // end if..
			} // end calculate the quantities of minnum..
			//cout << "period " << peri << " minnum is " << minnum[peri] << " it has " << minquentity[peri] << endl; //for debug
			for (int i=1;i!=minquentity[peri]+1;++i) // swap two value..
			{
				for (int a=1;a!=minquentity[peri];++a)
				{
					for (int b=a+1;b!=minquentity[peri]+1;++b)
					{
						if (q[temp + a] > q[temp + b] )
						{
							int swaptemp;
							swaptemp=q[temp+a];
							q[temp+a]=q[temp+b];
							q[temp+b]=swaptemp;
							pos[peri][i]=temp+b;
						}
					}
				}
				//if (minnum[peri] < q[temp+i])
				if ( pos[peri][i] > temp + minquentity[peri] )
				{
					int tempswap;
					tempswap = q[temp+i];
					q[temp+i] = q[pos[peri][i]];
					q[pos[peri][i]]=tempswap;
					++countnum;
				} // endif
			} //end for swap;
			temp+=minquentity[peri]; // last
		} // end of a period..
		if(countnum<=1)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;

#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
typedef long long ll;

int n, m, x, y;

// n - dotsCount[i] = # of hashes
int dotsCount[1000+9];			// +9 for safety and little thinking
int memo[1000+9][1000+9][3];	// 3: 0 (dots), 1 (hashes), 2 (nothing)

// 0-1 style with restrictions on # of connectives of same value
int solve(int col, int wid, int last)
{
	if(col == m)
	{
		// Make sure invalid states to invalidated
		/*if(wid < x || wid > y)
			return 100000000;*/
		return 0;	// we are done
	}

	int ans = -1;

	if(ans != -1)
		return ans;

	int dots = 100000000;	// max answer is 1000x1000
	// nothing before or bigger block is valid or old block is allowed
	if(col == 0 || (last == 0 && wid+1 <= y) || (last == 1 && wid >= x))
		dots = n - dotsCount[col] + solve(col+1, (last == 0) ? wid + 1 : 1, 0);

	int hashes = 100000000;
	if(col == 0 || (last == 1 && wid+1 <= y) || (last == 0 && wid >= x))
		hashes = dotsCount[col] + solve(col+1, (last == 1) ? wid + 1 : 1, 1);

	ans = min(dots, hashes);

	return ans;
}
// Your turn: Convert to tabulation style

int main() {
/*#ifndef ONLINE_JUDGE
	freopen("test.txt", "rt", stdin);
#endif*/

	cin>>n>>m>>x>>y;

	// read and accumulate each column
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			char ch;
			cin>>ch;

			if(ch == '.')
				dotsCount[j]++;
		}
	}

	clr(memo, -1);
	cout<<solve(0, 0, 2);

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define N 1005
int main()
{
	int n,m,x,y;
	int i,j,dp1[N],dp2[N],a[N];
	char ch;
	cin >>n>>m>>x>>y;
	{
		memset(a,0,sizeof(a));
		for(i=1;i<=n;i++)
		{
		   getchar();
		   for(j=1;j<=m;j++)
		   {
   			      cin >> ch;
				  if(ch=='#')a[j]++;
   		    }
		}
		 a[0]=0;
   		 for(i=1;i<=m;i++)
			a[i]+=a[i-1];
		 memset(dp1,127,sizeof(dp1));
		 memset(dp2,127,sizeof(dp2));
   	         dp1[0]=dp2[0]=0;
		 for(i=1;i<=m;i++)
		    for(j=x ; j<=y && j<=i ; j++)
			{
				dp1[i]=min(dp2[i-j]+a[i]-a[i-j],dp1[i]);
				dp2[i]=min(dp1[i-j]+j*n-(a[i]-a[i-j]),dp2[i]);
			}
		 cout <<min(dp1[m],dp2[m]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define N 1005
int main()
{
	int n,m,x,y;
	int i,j,dp1[N],dp2[N],a[N];
	char ch;
	cin >>n>>m>>x>>y;
	{
		memset(a,0,sizeof(a));
		for(i=1;i<=n;i++)
		{
		   getchar();
		   for(j=1;j<=m;j++)
		   {
   			      cin >> ch;
				  if(ch=='#')a[j]++;
   		    }
		}
		 a[0]=0;
   		 for(i=1;i<=m;i++)
			a[i]+=a[i-1];
		 memset(dp1,127,sizeof(dp1));
		 memset(dp2,127,sizeof(dp2));
   	         dp1[0]=dp2[0]=0;
		 for(i=1;i<=m;i++)
		    for(j=x ; j<=y && j<=i ; j++)
			{
				dp1[i]=dp2[i-j]+a[i]-a[i-j];
				dp2[i]=dp1[i-j]+j*n-(a[i]-a[i-j]);
			//	cout <<dp1[i]<<endl;
			//	cout <<dp2[i]<<endl;
			}
		 cout <<min(dp1[m],dp2[m]);
	}
	return 0;
}


#include<bits/stdc++.h>
#include<sstream>
#include<stdint.h>
using namespace std;
int n,m,x,y;
char a[1005][1005];
int white[1005],black[1005];
int dpb[1005],dpw[1005];
int main(){
   cin>>n>>m>>x>>y;

   for(int i=1;i<=n;i++){
       for(int j=1;j<=m;j++){
           cin>>a[i][j];
       }
   }
   for(int i=1;i<=m;i++){
       dpb[i] = 1000001;
       dpw[i] = 1000001;
   }
   for(int col=1;col<=m;col++){
       int w = 0,b=0;
       for(int row=1;row<=n;row++){
           if(a[row][col] == '.'){//white
               ++w;
           }
           else{
               ++b;
           }
       }
       white[col] = white[col-1] + w;
       black[col] = black[col-1] + b;
   }

   for(int i=x;i<=m;i++){
       for(int j=i-x+1;i-j+1<=y;j--){

            if(dpb[j-1] != 1000001){
              dpw[i] = min(black[i] - black[j-1] + dpb[j-1],dpw[i]);
            }
            if(dpw[j-1] != 1000001){
              dpb[i] = min(white[i] - white[j-1] + dpw[j-1],dpb[i]);
            }

       }

   }

   cout<<min(dpb[m],dpw[m])<<"\n";

   return 0;
}


#include<bits/stdc++.h>
#include<sstream>
#include<stdint.h>
using namespace std;
int n,m,x,y;
char a[1005][1005];
int white[1005],black[1005];
int dpb[1005],dpw[1005];
int main(){
   cin>>n>>m>>x>>y;

   for(int i=1;i<=n;i++){
       for(int j=1;j<=m;j++){
           cin>>a[i][j];
       }
   }
   for(int i=1;i<=m;i++){
       dpb[i] = 1000001;
       dpw[i] = 1000001;
   }
   for(int col=1;col<=m;col++){
       int w = 0,b=0;
       for(int row=1;row<=n;row++){
           if(a[row][col] == '.'){//white
               ++w;
           }
           else{
               ++b;
           }
       }
       white[col] = white[col-1] + w;
       black[col] = black[col-1] + b;
   }

   for(int i=x;i<=m;i++){
       for(int j=i-x+1;(j>=1 && i-j+1<=min(y,m));j--){

            if(dpb[j-1] != 1000001){
              dpw[i] = min(black[i] - black[j-1] + dpb[j-1],dpw[i]);
            }
            if(dpw[j-1] != 1000001){
              dpb[i] = min(white[i] - white[j-1] + dpw[j-1],dpb[i]);
            }

       }

   }

   cout<<min(dpb[m],dpw[m])<<"\n";

   return 0;
}


#include<bits/stdc++.h>
#include<sstream>
#include<stdint.h>
using namespace std;
int n,m,x,y;
char a[1005][1005];
int white[1005],black[1005];
int dpb[1005],dpw[1005];
int main(){
   cin>>n>>m>>x>>y;

   for(int i=1;i<=n;i++){
       for(int j=1;j<=m;j++){
           cin>>a[i][j];
       }
   }
   for(int i=1;i<=m;i++){
       dpb[i] = 1000000;
       dpw[i] = 1000000;
   }
   for(int col=1;col<=m;col++){
       int w = 0,b=0;
       for(int row=1;row<=n;row++){
           if(a[row][col] == '.'){//white
               ++w;
           }
           else{
               ++b;
           }
       }
       white[col] = white[col-1] + w;
       black[col] = black[col-1] + b;
   }

   for(int i=x;i<=m;i++){
       for(int j=i-x+1;i-j+1<=y;j--){

            dpw[i] = min(black[i] - black[j-1] + dpb[j-1],dpw[i]);

            dpb[i] = min(white[i] - white[j-1] + dpw[j-1],dpb[i]);

       }

   }

   cout<<min(dpb[m],dpw[m])<<"\n";

   return 0;
}


#include<bits/stdc++.h>
#include<sstream>
#include<stdint.h>
using namespace std;
int n,m,x,y;
char a[1005][1005];
int white[1005],black[1005];
int dpb[1005],dpw[1005];
int main(){
   cin>>n>>m>>x>>y;

   for(int i=1;i<=n;i++){
       for(int j=1;j<=m;j++){
           cin>>a[i][j];
       }
   }
   for(int i=1;i<=m;i++){
       dpb[i] = 1000001;
       dpw[i] = 1000001;
   }
   for(int col=1;col<=m;col++){
       int w = 0,b=0;
       for(int row=1;row<=n;row++){
           if(a[row][col] == '.'){//white
               ++w;
           }
           else{
               ++b;
           }
       }
       white[col] = white[col-1] + w;
       black[col] = black[col-1] + b;
   }

   for(int i=x;i<=m;i++){
       for(int j=i-x+1;i-j+1<=min(y,m);j--){

            if(dpb[j-1] != 1000001){
              dpw[i] = min(black[i] - black[j-1] + dpb[j-1],dpw[i]);
            }
            if(dpw[j-1] != 1000001){
              dpb[i] = min(white[i] - white[j-1] + dpw[j-1],dpb[i]);
            }

       }

   }

   cout<<min(dpb[m],dpw[m])<<"\n";

   return 0;
}


#include<bits/stdc++.h>
#include<sstream>
#include<stdint.h>
using namespace std;
int n,m,x,y;
char a[1005][1005];
int white[1005],black[1005];
int dpb[1005],dpw[1005];
int main(){
   cin>>n>>m>>x>>y;

   for(int i=1;i<=n;i++){
       for(int j=1;j<=m;j++){
           cin>>a[i][j];
       }
   }
   for(int i=1;i<=m;i++){
       dpb[i] = 9999999;
       dpw[i] = 9999999;
   }
   for(int col=1;col<=m;col++){
       int w = 0,b=0;
       for(int row=1;row<=n;row++){
           if(a[row][col] == '.'){//white
               ++w;
           }
           else{
               ++b;
           }
       }
       white[col] = white[col-1] + w;
       black[col] = black[col-1] + b;
   }

   for(int i=x;i<=m;i++){
       for(int j=i-x+1;i-j+1<=y;j--){

            dpw[i] = min(black[i] - black[j-1] + dpb[j-1],dpw[i]);

            dpb[i] = min(white[i] - white[j-1] + dpw[j-1],dpb[i]);

       }

   }

   cout<<min(dpb[m],dpw[m])<<"\n";

   return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int n, m, x, y;
long long pre[1111];
long long dp[1111][1111][3];

long long calc (int i, bool color) {
  if (!color) return n - pre[i];
  return pre[i];
}

long long go (int c, int size, bool color) {
  if (c == m) {
    if (size < x || size > y) return 1e6;
    return 0;
  }

  if (dp[c][size][color] != -1) return dp[c][size][color];

  long long best = LLONG_MAX;
  long long cost;

  if (size < x) {
    cost = calc(c, color);
    best = min(best, cost + go(c + 1, size + 1, color));
  }
  else {
    if (size + 1 <= y) {
      cost = calc(c, color);
      best = min(best, cost + go(c + 1, size + 1, color));
    }

    cost = calc(c, !color);
    best = min(best, cost + go(c + 1, 1, !color));
  }

  return dp[c][size][color] = best;
}

int main() {
  while (cin >> n >> m >> x >> y) {
    memset(pre, 0, sizeof pre);
    vector<string> mat(n);
    for (int i = 0; i < n; ++i) cin >> mat[i];

    for (int i = 0; i < m; ++i) {
      int cnt = 0;
      for (int j = 0; j < n; ++j) {
        if (mat[j][i] == '#') cnt ++;
      }

      pre[i] = n - cnt;
    }

    memset(dp, -1, sizeof dp);
    cout << min(go(0, 0, 0), go(0, 0, 1)) << endl;
  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int n, m, x, y;
vector<int> pre(1111, 0);
int dp[1111][1111][3];

int calc (int i, bool color) {
  if (!color) return n - (pre[i + 1] - pre[i]);
  return pre[i + 1] - pre[i];
}

int go (int c, int size, bool color) {
  if (c == m) {
    return 0;
  }

  if (dp[c][size][color] != -1) return dp[c][size][color];

  int best = INT_MAX;
  int cost;

  if (size < x) {
    cost = calc(c, color);
    best = min(best, cost + go(c + 1, size + 1, color));
  }
  else {
    if (size + 1 <= y) {
      cost = calc(c, color);
      best = min(best, cost + go(c + 1, size + 1, color));
    }

    cost = calc(c, !color);
    best = min(best, cost + go(c + 1, 1, !color));
  }

  return dp[c][size][color] = best;
}

int main() {
  while (cin >> n >> m >> x >> y) {
    for (int i = 0; i < pre.size(); ++i) pre[i] = 0;
    vector<string> mat(n);
    for (int i = 0; i < n; ++i) cin >> mat[i];

    for (int i = 1; i <= m; ++i) {
      int cnt = 0;
      for (int j = 0; j < n; ++j) {
        if (mat[j][i - 1] == '#') cnt ++;
      }

      pre[i] = pre[i - 1] + (n - cnt);
    }

    memset(dp, -1, sizeof dp);
    cout << go(0, 0, 0) << endl;
  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int n, m, x, y;
long long pre[111];
long long dp[1111][1111][3];

long long calc (int i, bool color) {
  if (!color) return n - pre[i];
  return pre[i];
}

long long go (int c, int size, bool color) {
  if (c == m) {
    if (size < x || size > y) return 1e6;
    return 0;
  }

  if (dp[c][size][color] != -1) return dp[c][size][color];

  long long best = LLONG_MAX;
  long long cost;

  if (size < x) {
    cost = calc(c, color);
    best = min(best, cost + go(c + 1, size + 1, color));
  }
  else {
    if (size + 1 <= y) {
      cost = calc(c, color);
      best = min(best, cost + go(c + 1, size + 1, color));
    }

    cost = calc(c, !color);
    best = min(best, cost + go(c + 1, 1, !color));
  }

  return dp[c][size][color] = best;
}

int main() {
  while (cin >> n >> m >> x >> y) {
    memset(pre, 0, sizeof pre);
    vector<string> mat(n);
    for (int i = 0; i < n; ++i) cin >> mat[i];

    for (int i = 0; i < m; ++i) {
      int cnt = 0;
      for (int j = 0; j < n; ++j) {
        if (mat[j][i] == '#') cnt ++;
      }

      pre[i] = n - cnt;
    }

    memset(dp, -1, sizeof dp);
    cout << min(go(0, 0, 0), go(0, 0, 1)) << endl;
  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int n, m, x, y;
int pre[111];
int dp[1111][1111][3];

int calc (int i, bool color) {
  if (!color) return n - pre[i];
  return pre[i];
}

int go (int c, int size, bool color) {
  if (c == m) {
    if (size < x || size > y) return 1e6;
    return 0;
  }

  if (dp[c][size][color] != -1) return dp[c][size][color];

  int best = 2 * 1e6;
  int cost;

  if (size < x) {
    cost = calc(c, color);
    best = min(best, cost + go(c + 1, size + 1, color));
  }
  else {
    if (size + 1 <= y) {
      cost = calc(c, color);
      best = min(best, cost + go(c + 1, size + 1, color));
    }

    cost = calc(c, !color);
    best = min(best, cost + go(c + 1, 1, !color));
  }

  return dp[c][size][color] = best;
}

int main() {
  while (cin >> n >> m >> x >> y) {
    memset(pre, 0, sizeof pre);
    vector<string> mat(n);
    for (int i = 0; i < n; ++i) cin >> mat[i];

    for (int i = 0; i < m; ++i) {
      int cnt = 0;
      for (int j = 0; j < n; ++j) {
        if (mat[j][i] == '#') cnt ++;
      }

      pre[i] = n - cnt;
    }

    memset(dp, -1, sizeof dp);

    cout << min(go(0, 0, 0), go(0, 0, 1)) << endl;
  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define __ ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define foreach(it, x) for (__typeof (x).begin() it = (x).begin(); it != (x).end(); ++it)
#define all(x) x.begin(),x.end()
#define D(x) cout << #x " = " << (x) << endl;

template <class T> string toStr(const T &x)
{ stringstream s; s << x; return s.str(); }

template <class T> int toInt(const T &x)
{ stringstream s; s << x; int r; s >> r; return r; }

int dx[8] = {-1,-1,-1,0,1,1, 1, 0};
int dy[8] = {-1, 0, 1,1,1,0,-1,-1};

int main() {
  int n,m,x,y;
  cin >> n >> m >> x >> y;

  int mat[n][m];
  for (int i = 0; i < n; ++i) {
    string line;
    cin >> line;
    for (int j = 0; j < m; ++j) {
      mat[i][j] = line[j];
    }
  }

  vector< pair<int, int> > v;
  for (int i = 0; i < m; ++i) {
    int cnt = 0;
    for (int j = 0; j < n; ++j) {
      if (mat[j][i] == '#') cnt ++;
    }
    v.push_back(make_pair(n - cnt, cnt));
  }

  int ans = 0;
  sort(all(v));

  int i = 0;
  for (i = 0; i < x; ++i) ans += v[i].first;

  int cnt = x;
  while (cnt < y) {
    if (v[i].first > v[i].second) break;
    ans += v[i].first;
    i ++;
    cnt ++;
  }

  while (cnt < m) ans += v[cnt++].second;

  cout << ans;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m,x,y,i,j;
    cin>>n>>m>>x>>y;
    char ch[n+1][m+1];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        cin>>ch[i][j];
    }
    vector <ll> white(m+1,0),black(m+1,0);
    ll dp[m+1][2];
    for(j=1;j<=m;j++)
    {
        for(i=1;i<=n;i++)
        {
            if(ch[i][j]=='.')
            white[j]++;
            else
            black[j]++;
        }
    }
    for(j=1;j<=m;j++)
    white[j]+=white[j-1];
    for(j=1;j<=m;j++)
    black[j]+=black[j-1];
    dp[0][0]=0,dp[0][1]=0;
    for(j=1;j<x && j<=m;j++)
    dp[j][0]=1e9+7,dp[j][1]=1e9+7;
    for(j=x;j<=y && j<=m;j++)
    dp[j][0]=white[j],dp[j][1]=black[j];
    for(j=x;j<=m;j++)
    {
        for(i=x;i<=y;i++)
        {
            if(j-i>=0)
            dp[j][0]=min(dp[j][0],dp[j-i][1]+white[j]-white[j-i]);
        }
        for(i=x;i<=y;i++)
        {
            if(j-i>=0)
            dp[j][1]=min(dp[j][1],dp[j-i][0]+black[j]-black[j-i]);
        }
    }
    cout<<min(dp[m][1],dp[m][0]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m,x,y,i,j;
    cin>>n>>m>>x>>y;
    char ch[n+1][m+1];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        cin>>ch[i][j];
    }
    vector <ll> white(m+1,0),black(m+1,0);
    ll dp[m+1][2];
    for(j=1;j<=m;j++)
    {
        for(i=1;i<=n;i++)
        {
            if(ch[i][j]=='.')
            white[j]++;
            else
            black[j]++;
        }
    }
    for(j=1;j<=m;j++)
    white[j]+=white[j-1];
    for(j=1;j<=m;j++)
    black[j]+=black[j-1];
    dp[0][0]=0,dp[0][1]=0;
    for(j=1;j<=m;j++)
    dp[j][0]=1e9+7,dp[j][1]=1e9+7;
    for(i=0;i<=m;i++)
    {
        for(j=x;j<=y && i+j<=m;j++)
        dp[i+j][0]=min(dp[i+j][0],dp[i][1]+white[i+j]-white[i]);
        for(j=x;j<=y && i+j<=m;j++)
        dp[i+j][1]=min(dp[i+j][1],dp[i][0]+black[i+j]-black[i]);
    }
    cout<<min(dp[m][1],dp[m][0]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m,x,y,i,j;
    cin>>n>>m>>x>>y;
    char ch[n+1][m+1];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        cin>>ch[i][j];
    }
    vector <ll> white(m+1,0),black(m+1,0);
    ll dp[2][m+1];
    for(j=1;j<=m;j++)
    {
        for(i=1;i<=n;i++)
        {
            if(ch[i][j]=='.')
            white[j]++;
            else
            black[j]++;
        }
    }
    for(j=1;j<=m;j++)
    white[j]+=white[j-1];
    for(j=1;j<=m;j++)
    black[j]+=black[j-1];
    for(int j=1;j<x;j++)
    dp[j][0]=1e9+7,dp[j][1]=1e9+7;
    for(j=x;j<=m;j++)
    {
        dp[j][0]=1e9+7,dp[j][1]=1e9+7;
        for(i=x;i<=y;i++)
        {
            if(j-i<1)
            dp[j][0]=white[j];
            else
            dp[j][0]=min(dp[j][0],dp[j-i][1]+white[j]-white[j-i]);
        }
        for(i=x;i<=y;i++)
        {
            if(j<=x || j-i<1)
            dp[j][1]=black[j];
            else
            dp[j][1]=min(dp[j][1],dp[j-i][0]+black[j]-black[j-i]);
        }
    }
    cout<<min(dp[m][1],dp[m][0]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m,x,y,i,j;
    cin>>n>>m>>x>>y;
    char ch[n+1][m+1];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        cin>>ch[i][j];
    }
    vector <ll> white(m+1,0),black(m+1,0);
    ll dp[m+1][2];
    for(j=1;j<=m;j++)
    {
        for(i=1;i<=n;i++)
        {
            if(ch[i][j]=='.')
            white[j]++;
            else
            black[j]++;
        }
    }
    for(j=1;j<=m;j++)
    white[j]+=white[j-1];
    for(j=1;j<=m;j++)
    black[j]+=black[j-1];
    dp[0][0]=0,dp[0][1]=0;
    for(int j=1;j<x && j<=m;j++)
    dp[j][0]=1e9+7,dp[j][1]=1e9+7;
    for(int j=x;j<=y && j<=m;j++)
    dp[j][0]=white[j],dp[j][1]=black[j];
    for(j=x;j<=m;j++)
    {
        for(i=x;i<=y;i++)
        {
            if(j-i>=0)
            dp[j][0]=min(dp[j][0],dp[j-i][1]+white[j]-white[j-i]);
        }
        for(i=x;i<=y;i++)
        {
            if(j-i>=0)
            dp[j][1]=min(dp[j][1],dp[j-i][0]+black[j]-black[j-i]);
        }
    }
    cout<<min(dp[m][1],dp[m][0]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[1001][2],table[1001][2],cc[1001][2],n,m,x,y;
char ch[1001][1001];
ll func(ll i,ll c)
{
    if(table[i][c]!=-1)
    return dp[i][c];
    if(i==0)
    {
        table[i][c]=1;
        return dp[i][c]=0;
    }
    if(i<x)
    {
        table[i][c]=1;
        return dp[i][c];
    }
    for(ll j=x;j<=y;j++)
    {
        if(i-j>=0)
        dp[i][c]=min(dp[i][c],func(i-j,1-c)+cc[i][1-c]-cc[i-j][1-c]);
    }
    table[i][c]=1;
    return dp[i][c];
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    memset(dp,1e9+7,sizeof(dp));
    memset(table,-1,sizeof(table));
    memset(cc,0,sizeof(cc));
    cin>>n>>m>>x>>y;
    ll i,j;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        cin>>ch[i][j];
    }
    for(j=1;j<=m;j++)
    {
        for(i=1;i<=n;i++)
        {
            if(ch[i][j]=='.')
            cc[j][0]++;
            else
            cc[j][1]++;
        }
    }
    for(j=1;j<=m;j++)
    cc[j][0]+=cc[j-1][0],cc[j][1]+=cc[j-1][1];
    ll ans=min(func(m,1),func(m,0));
    cout<<ans<<"\n";
    return 0;
}


//Bismillahir Rahmanir Rahim
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<bitset>
#include<ctime>
using namespace std;

#define i64 long long int
#define u64 unsigned long long int

#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)

#define repc(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define repr(i,a,b) for(__typeof(b) i=(a); i>=(b); i--)

#define clr(a) a.clear()
#define sz(a) (int)a.size()
#define mem(a,b) memset(a,b,sizeof a)
#define ERASE(a) a.erase(a.begin(),a.end())

#define sc scanf
#define S(z) scanf("%d",&z)
#define S2(xx,zz) scanf("%d %d",&xx,&zz)
#define SC(z) scanf("%s",&z)

#define pf printf
#define pfn printf("\n")
#define PF(z) printf("%d",z)
#define PF2(x,y) printf("%d %d",x,y)
#define PFL(z) printf("%I64d",z)
#define PFS(z) printf("%s",z)

#define MI map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define SI set<int>
#define SS set<string>
#define SMI multiset<int>
#define VI vector<int>
#define VI2 vector < vector < int > >
#define QU queue<int>
#define PQU priority_queue<int>
#define STK stack<int>
#define pb push_back

#define inf 2000000000
#define pi  acos(-1.0)
#define MAX 1000007
#define MOD 1000000007
#define eps 1e-9

template <class T>T sqr(T x) {return x*x;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0) return 1;
    if(e%2==0){i64 t=bigmod(p,e/2,M);return (T)((t*t)%M);}
    return (T)((i64)bigmod(p,e-1,M)*(i64)p)%M;
}
template <class T> inline T bigexp(T p,T e)
{
    if(e==0)return 1;
    if(e%2==0){i64 t=bigexp(p,e/2);return (T)((t*t));}
    return (T)((i64)bigexp(p,e-1)*(i64)p);
}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

int dx4[]={1,0,-1,0};int dy4[]={0,1,0,-1}; //4 Direction
int dx8[]={1,1,0,-1,-1,-1,0,1};int dy8[]={0,1,1,1,0,-1,-1,-1};//8 direction
int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
/*
struct Graph
{
    int u,v,w;
    bool operator<(const Graph& p)
    const {return w<p.w;} // oporerta chotor jnne
}edge[10];

vector<int>edges,cost;
int l=lower_bound(a+1,a+5,4)-a;
///amake 1 theke 5 tomo index porjnto search dibe. jdi match khay taile oi index i or na match khele 1 add kore dibe.
int u=upper_bound(a+1,a+5,18)-a;
///amake 1 theke 5 tomo index porjnto search dibe. match khakor na khak 1 add kore dibe.
//***last e ekta extra largest element both khetre add korte hbe.
*/
/******************* Code Starts here *******************/

int n,m,x,y,a[1005],b[1005],dp[1005][1005][2];
char s[1005][1005];

int call(int pos, int num ,int col)
{
    if(pos>m) return 0;
    int sum=0,ret1=2000000000;
    if(col==0)
    {
        for(int i=pos;i<=pos+x-2;i++) sum+=a[i];
        for(int i=pos+x-1;i<=pos+y-1;i++)
        {
            sum+=a[i];
            ret1=min(ret1,sum+call(i+1,i-(pos+x-1)+1,1));
        }
    }
    else if(col==1)
    {
        for(int i=pos;i<=pos+x-2;i++) sum+=b[i];
        for(int i=pos+x-1;i<=pos+y-1;i++)
        {
            sum+=b[i];
            ret1=min(ret1,sum+call(i+1,i-(pos+x-1)+1,0));
        }
    }
    return ret1;
}

int main()
{
    S2(n,m);S2(x,y);
    repc(i,0,n-1)
    {
        SC(s[i]);
    }
    mem(dp,-1);
    repc(i,0,m-1)
    {
        repc(j,0,n-1)
        if(s[j][i]=='.') b[i+1]++;
        else a[i+1]++;
    }
    int res=min(call(1,0,0),call(1,0,1));
    pf("%d\n",res);
    return 0;
}


//Bismillahir Rahmanir Rahim
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<bitset>
#include<ctime>
using namespace std;

#define i64 long long int
#define u64 unsigned long long int

#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)

#define repc(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define repr(i,a,b) for(__typeof(b) i=(a); i>=(b); i--)

#define clr(a) a.clear()
#define sz(a) (int)a.size()
#define mem(a,b) memset(a,b,sizeof a)
#define ERASE(a) a.erase(a.begin(),a.end())

#define sc scanf
#define S(z) scanf("%d",&z)
#define S2(xx,zz) scanf("%d %d",&xx,&zz)
#define SC(z) scanf("%s",&z)

#define pf printf
#define pfn printf("\n")
#define PF(z) printf("%d",z)
#define PF2(x,y) printf("%d %d",x,y)
#define PFL(z) printf("%I64d",z)
#define PFS(z) printf("%s",z)

#define MI map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define SI set<int>
#define SS set<string>
#define SMI multiset<int>
#define VI vector<int>
#define VI2 vector < vector < int > >
#define QU queue<int>
#define PQU priority_queue<int>
#define STK stack<int>
#define pb push_back

#define inf 2000000000
#define pi  acos(-1.0)
#define MAX 1000007
#define MOD 1000000007
#define eps 1e-9

template <class T>T sqr(T x) {return x*x;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0) return 1;
    if(e%2==0){i64 t=bigmod(p,e/2,M);return (T)((t*t)%M);}
    return (T)((i64)bigmod(p,e-1,M)*(i64)p)%M;
}
template <class T> inline T bigexp(T p,T e)
{
    if(e==0)return 1;
    if(e%2==0){i64 t=bigexp(p,e/2);return (T)((t*t));}
    return (T)((i64)bigexp(p,e-1)*(i64)p);
}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

int dx4[]={1,0,-1,0};int dy4[]={0,1,0,-1}; //4 Direction
int dx8[]={1,1,0,-1,-1,-1,0,1};int dy8[]={0,1,1,1,0,-1,-1,-1};//8 direction
int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
/*
struct Graph
{
    int u,v,w;
    bool operator<(const Graph& p)
    const {return w<p.w;} // oporerta chotor jnne
}edge[10];

vector<int>edges,cost;
int l=lower_bound(a+1,a+5,4)-a;
///amake 1 theke 5 tomo index porjnto search dibe. jdi match khay taile oi index i or na match khele 1 add kore dibe.
int u=upper_bound(a+1,a+5,18)-a;
///amake 1 theke 5 tomo index porjnto search dibe. match khakor na khak 1 add kore dibe.
//***last e ekta extra largest element both khetre add korte hbe.
*/
/******************* Code Starts here *******************/

int n,m,x,y,a[1005],b[1005],dp[1005][1005][2];
char s[1005][1005];
bool dp1[1005][1005][2];

int call(int pos, int num ,int col)
{
    if(pos>m) return 0;
    if(pos+x-1>m) return 2000000000;
    if(dp1[pos][num][col]==true) dp[pos][num][col];
    dp1[pos][num][col]=true;
    int sum=0,ret1=2000000000;
    if(col==0)
    {
        for(int i=pos;i<=pos+x-2;i++) sum+=a[i];
        int mn=min(m,pos+y-1);
        for(int i=pos+x-1;i<=mn;i++)
        {
            sum+=a[i];
            ret1=min(ret1,sum+call(i+1,i-(pos+x-1)+1,1));
        }
    }
    else if(col==1)
    {
        for(int i=pos;i<=pos+x-2;i++) sum+=b[i];
        int mn=min(m,pos+y-1);
        for(int i=pos+x-1;i<=mn;i++)
        {
            sum+=b[i];
            ret1=min(ret1,sum+call(i+1,i-(pos+x-1)+1,0));
        }
    }
    return dp[pos][num][col]=ret1;
}

int main()
{
    S2(n,m);S2(x,y);
    repc(i,0,n-1)
    {
        SC(s[i]);
    }
    //
    repc(i,0,m-1)
    {
        repc(j,0,n-1)
        if(s[j][i]=='.') b[i+1]++;
        else a[i+1]++;
    }
    int res=min(call(1,0,0),call(1,0,1));
    pf("%d\n",res);
    return 0;
}


//Bismillahir Rahmanir Rahim
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<bitset>
#include<ctime>
using namespace std;

#define i64 long long int
#define u64 unsigned long long int

#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)

#define repc(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define repr(i,a,b) for(__typeof(b) i=(a); i>=(b); i--)

#define clr(a) a.clear()
#define sz(a) (int)a.size()
#define mem(a,b) memset(a,b,sizeof a)
#define ERASE(a) a.erase(a.begin(),a.end())

#define sc scanf
#define S(z) scanf("%d",&z)
#define S2(xx,zz) scanf("%d %d",&xx,&zz)
#define SC(z) scanf("%s",&z)

#define pf printf
#define pfn printf("\n")
#define PF(z) printf("%d",z)
#define PF2(x,y) printf("%d %d",x,y)
#define PFL(z) printf("%I64d",z)
#define PFS(z) printf("%s",z)

#define MI map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define SI set<int>
#define SS set<string>
#define SMI multiset<int>
#define VI vector<int>
#define VI2 vector < vector < int > >
#define QU queue<int>
#define PQU priority_queue<int>
#define STK stack<int>
#define pb push_back

#define inf 2000000000
#define pi  acos(-1.0)
#define MAX 1000007
#define MOD 1000000007
#define eps 1e-9

template <class T>T sqr(T x) {return x*x;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0) return 1;
    if(e%2==0){i64 t=bigmod(p,e/2,M);return (T)((t*t)%M);}
    return (T)((i64)bigmod(p,e-1,M)*(i64)p)%M;
}
template <class T> inline T bigexp(T p,T e)
{
    if(e==0)return 1;
    if(e%2==0){i64 t=bigexp(p,e/2);return (T)((t*t));}
    return (T)((i64)bigexp(p,e-1)*(i64)p);
}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

int dx4[]={1,0,-1,0};int dy4[]={0,1,0,-1}; //4 Direction
int dx8[]={1,1,0,-1,-1,-1,0,1};int dy8[]={0,1,1,1,0,-1,-1,-1};//8 direction
int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
/*
struct Graph
{
    int u,v,w;
    bool operator<(const Graph& p)
    const {return w<p.w;} // oporerta chotor jnne
}edge[10];

vector<int>edges,cost;
int l=lower_bound(a+1,a+5,4)-a;
///amake 1 theke 5 tomo index porjnto search dibe. jdi match khay taile oi index i or na match khele 1 add kore dibe.
int u=upper_bound(a+1,a+5,18)-a;
///amake 1 theke 5 tomo index porjnto search dibe. match khakor na khak 1 add kore dibe.
//***last e ekta extra largest element both khetre add korte hbe.
*/
/******************* Code Starts here *******************/

int n,m,x,y,a[1005],b[1005],dp[1005][1005][2];
char s[1005][1005];

int call(int pos, int num ,int col)
{
    if(pos>m) return 0;
    if(pos+x-1>m) return 2000000000;
    if(dp[pos][num][col]!=-1) dp[pos][num][col];
    int sum=0,ret1=2000000000;
    if(col==0)
    {
        for(int i=pos;i<=pos+x-2;i++) sum+=a[i];
        int mn=min(m,pos+y-1);
        for(int i=pos+x-1;i<=mn;i++)
        {
            sum+=a[i];
            ret1=min(ret1,sum+call(i+1,i-(pos+x-1)+1,1));
        }
    }
    else if(col==1)
    {
        for(int i=pos;i<=pos+x-2;i++) sum+=b[i];
        int mn=min(m,pos+y-1);
        for(int i=pos+x-1;i<=mn;i++)
        {
            sum+=b[i];
            ret1=min(ret1,sum+call(i+1,i-(pos+x-1)+1,0));
        }
    }
    return dp[pos][num][col]=ret1;
}

int main()
{
    S2(n,m);S2(x,y);
    repc(i,0,n-1)
    {
        SC(s[i]);
    }
    mem(dp,-1);
    repc(i,0,m-1)
    {
        repc(j,0,n-1)
        if(s[j][i]=='.') b[i+1]++;
        else a[i+1]++;
    }
    int res=min(call(1,0,0),call(1,0,1));
    pf("%d\n",res);
    return 0;
}


//Bismillahir Rahmanir Rahim
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<bitset>
#include<ctime>
using namespace std;

#define i64 long long int
#define u64 unsigned long long int

#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)

#define repc(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define repr(i,a,b) for(__typeof(b) i=(a); i>=(b); i--)

#define clr(a) a.clear()
#define sz(a) (int)a.size()
#define mem(a,b) memset(a,b,sizeof a)
#define ERASE(a) a.erase(a.begin(),a.end())

#define sc scanf
#define S(z) scanf("%d",&z)
#define S2(xx,zz) scanf("%d %d",&xx,&zz)
#define SC(z) scanf("%s",&z)

#define pf printf
#define pfn printf("\n")
#define PF(z) printf("%d",z)
#define PF2(x,y) printf("%d %d",x,y)
#define PFL(z) printf("%I64d",z)
#define PFS(z) printf("%s",z)

#define MI map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define SI set<int>
#define SS set<string>
#define SMI multiset<int>
#define VI vector<int>
#define VI2 vector < vector < int > >
#define QU queue<int>
#define PQU priority_queue<int>
#define STK stack<int>
#define pb push_back

#define inf 2000000000
#define pi  acos(-1.0)
#define MAX 1000007
#define MOD 1000000007
#define eps 1e-9

template <class T>T sqr(T x) {return x*x;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0) return 1;
    if(e%2==0){i64 t=bigmod(p,e/2,M);return (T)((t*t)%M);}
    return (T)((i64)bigmod(p,e-1,M)*(i64)p)%M;
}
template <class T> inline T bigexp(T p,T e)
{
    if(e==0)return 1;
    if(e%2==0){i64 t=bigexp(p,e/2);return (T)((t*t));}
    return (T)((i64)bigexp(p,e-1)*(i64)p);
}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

int dx4[]={1,0,-1,0};int dy4[]={0,1,0,-1}; //4 Direction
int dx8[]={1,1,0,-1,-1,-1,0,1};int dy8[]={0,1,1,1,0,-1,-1,-1};//8 direction
int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
/*
struct Graph
{
    int u,v,w;
    bool operator<(const Graph& p)
    const {return w<p.w;} // oporerta chotor jnne
}edge[10];

vector<int>edges,cost;
int l=lower_bound(a+1,a+5,4)-a;
///amake 1 theke 5 tomo index porjnto search dibe. jdi match khay taile oi index i or na match khele 1 add kore dibe.
int u=upper_bound(a+1,a+5,18)-a;
///amake 1 theke 5 tomo index porjnto search dibe. match khakor na khak 1 add kore dibe.
//***last e ekta extra largest element both khetre add korte hbe.
*/
/******************* Code Starts here *******************/

int n,m,x,y,a[1005],b[1005],dp[1005][1005][2];
char s[1005][1005];
bool dp1[1005][1005][2];

int call(int pos, int num ,int col)
{
    if(pos>m) return 0;
    if(pos+x-1>m) return 2000000000;
    if(dp1[pos][num][col]==true) dp[pos][num][col];
    dp1[pos][num][col]=true;
    int sum=0,ret1=2000000000;
    if(col==0)
    {
        for(int i=pos;i<=pos+x-2;i++) sum+=a[i];
        int mn=min(m,pos+y-1);
        for(int i=pos+x-1;i<=mn;i++)
        {
            sum+=a[i];
            ret1=min(ret1,sum+call(i+1,i-(pos+x-1)+1,1));
        }
    }
    else if(col==1)
    {
        for(int i=pos;i<=pos+x-2;i++) sum+=b[i];
        int mn=min(m,pos+y-1);
        for(int i=pos+x-1;i<=mn;i++)
        {
            sum+=b[i];
            ret1=min(ret1,sum+call(i+1,i-(pos+x-1)+1,0));
        }
    }
    return dp[pos][num][col]=ret1;
}

int main()
{
    S2(n,m);S2(x,y);
    repc(i,0,n-1)
    {
        SC(s[i]);
    }
    //
    repc(i,0,m-1)
    {
        repc(j,0,n-1)
        if(s[j][i]=='.') b[i+1]++;
        else a[i+1]++;
    }
    int res=call(1,0,0);
    pf("%d\n",res);
    return 0;
}


//Bismillahir Rahmanir Rahim
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<bitset>
#include<ctime>
#include<bits/stdc++.h>
using namespace std;

#define i64 long long int
#define u64 unsigned long long int

#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)

#define repc(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define repr(i,a,b) for(__typeof(b) i=(a); i>=(b); i--)

#define clr(a) a.clear()
#define sz(a) (int)a.size()
#define mem(a,b) memset(a,b,sizeof a)
#define ERASE(a) a.erase(a.begin(),a.end())

#define sc scanf
#define S(z) scanf("%d",&z)
#define S2(xx,zz) scanf("%d %d",&xx,&zz)
#define SC(z) scanf("%s",&z)

#define pf printf
#define pfn printf("\n")
#define PF(z) printf("%d",z)
#define PF2(x,y) printf("%d %d",x,y)
#define PFL(z) printf("%I64d",z)
#define PFS(z) printf("%s",z)

#define MI map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define SI set<int>
#define SS set<string>
#define SMI multiset<int>
#define VI vector<int>
#define VI2 vector < vector < int > >
#define QU queue<int>
#define PQU priority_queue<int>
#define STK stack<int>
#define pb push_back

#define inf 2000000000
#define pi  acos(-1.0)
#define MAX 1000007
#define MOD 1000000007
#define eps 1e-9

template <class T>T sqr(T x) {return x*x;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0) return 1;
    if(e%2==0){i64 t=bigmod(p,e/2,M);return (T)((t*t)%M);}
    return (T)((i64)bigmod(p,e-1,M)*(i64)p)%M;
}
template <class T> inline T bigexp(T p,T e)
{
    if(e==0)return 1;
    if(e%2==0){i64 t=bigexp(p,e/2);return (T)((t*t));}
    return (T)((i64)bigexp(p,e-1)*(i64)p);
}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

int dx4[]={1,0,-1,0};int dy4[]={0,1,0,-1}; //4 Direction
int dx8[]={1,1,0,-1,-1,-1,0,1};int dy8[]={0,1,1,1,0,-1,-1,-1};//8 direction
int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
/*
struct Graph
{
    int u,v,w;
    bool operator<(const Graph& p)
    const {return w<p.w;} // oporerta chotor jnne
}edge[10];

vector<int>edges,cost;
int l=lower_bound(a+1,a+5,4)-a;
///amake 1 theke 5 tomo index porjnto search dibe. jdi match khay taile oi index i or na match khele 1 add kore dibe.
int u=upper_bound(a+1,a+5,18)-a;
///amake 1 theke 5 tomo index porjnto search dibe. match khorok na khak 1 add kore dibe.
//***last e ekta extra largest element both khetre add korte hbe.
*/
/******************* Code Starts here *******************/

int n,m,x,y,a[1005],b[1005],dp[1005][2],sum1[1005],sum[1005];
char s[1005][1005];

bool dp1[1005][2];

int call(int pos,int col)
{
    if(pos>m) return 0;
    if(pos+x-1>m) return 2000000000;
    if(dp1[pos][col]==true) return dp[pos][col];
    dp1[pos][col]=true;

    int summ=0,ret1=2000000000;
    if(col==0)
    {
        summ=sum[pos+x-2]-sum[pos-1];
        int mn=min(m,pos+y-1);
        if(pos+1+x-1>m)
        {
            return dp[pos][col]=sum[m]-sum[pos-1];

        }
        for(int i=pos+x-1;i<=mn;i++)
        {
            summ+=a[i];
            ret1=min(ret1,summ+call(i+1,1));
        }
    }
    else if(col==1)
    {
        summ=sum1[pos+x-2]-sum1[pos-1];
        int mn=min(m,pos+y-1);
        if(pos+1+x-1>m)
        {
            return dp[pos][col]=sum1[m]-sum1[pos-1];

        }
        for(int i=pos+x-1;i<=mn;i++)
        {
            summ+=b[i];
            ret1=min(ret1,summ+call(i+1,0));
        }
    }
    return dp[pos][col]=ret1;
}

int main()
{
    S2(n,m);S2(x,y);
    repc(i,0,n-1)
    {
        SC(s[i]);
    }
    repc(i,0,m-1)
    {
        repc(j,0,n-1)
        if(s[j][i]=='.') b[i+1]++;
        else a[i+1]++;
    }
    repc(i,1,m) sum[i]+=sum[i-1]+a[i];
    repc(i,1,m) sum1[i]+=sum1[i-1]+b[i];
     int res=min(call(1,0),call(1,1));
    pf("%d\n",res);
    return 0;
}


//Bismillahir Rahmanir Rahim
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<bitset>
#include<ctime>
using namespace std;

#define i64 long long int
#define u64 unsigned long long int

#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)

#define repc(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define repr(i,a,b) for(__typeof(b) i=(a); i>=(b); i--)

#define clr(a) a.clear()
#define sz(a) (int)a.size()
#define mem(a,b) memset(a,b,sizeof a)
#define ERASE(a) a.erase(a.begin(),a.end())

#define sc scanf
#define S(z) scanf("%d",&z)
#define S2(xx,zz) scanf("%d %d",&xx,&zz)
#define SC(z) scanf("%s",&z)

#define pf printf
#define pfn printf("\n")
#define PF(z) printf("%d",z)
#define PF2(x,y) printf("%d %d",x,y)
#define PFL(z) printf("%I64d",z)
#define PFS(z) printf("%s",z)

#define MI map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define SI set<int>
#define SS set<string>
#define SMI multiset<int>
#define VI vector<int>
#define VI2 vector < vector < int > >
#define QU queue<int>
#define PQU priority_queue<int>
#define STK stack<int>
#define pb push_back

#define inf 2000000000
#define pi  acos(-1.0)
#define MAX 1000007
#define MOD 1000000007
#define eps 1e-9

template <class T>T sqr(T x) {return x*x;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0) return 1;
    if(e%2==0){i64 t=bigmod(p,e/2,M);return (T)((t*t)%M);}
    return (T)((i64)bigmod(p,e-1,M)*(i64)p)%M;
}
template <class T> inline T bigexp(T p,T e)
{
    if(e==0)return 1;
    if(e%2==0){i64 t=bigexp(p,e/2);return (T)((t*t));}
    return (T)((i64)bigexp(p,e-1)*(i64)p);
}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

int dx4[]={1,0,-1,0};int dy4[]={0,1,0,-1}; //4 Direction
int dx8[]={1,1,0,-1,-1,-1,0,1};int dy8[]={0,1,1,1,0,-1,-1,-1};//8 direction
int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
/*
struct Graph
{
    int u,v,w;
    bool operator<(const Graph& p)
    const {return w<p.w;} // oporerta chotor jnne
}edge[10];

vector<int>edges,cost;
int l=lower_bound(a+1,a+5,4)-a;
///amake 1 theke 5 tomo index porjnto search dibe. jdi match khay taile oi index i or na match khele 1 add kore dibe.
int u=upper_bound(a+1,a+5,18)-a;
///amake 1 theke 5 tomo index porjnto search dibe. match khakor na khak 1 add kore dibe.
//***last e ekta extra largest element both khetre add korte hbe.
*/
/******************* Code Starts here *******************/

int n,m,x,y,a[1005],b[1005],dp[1005][1005][2],sum1[1005],sum[1005];
char s[1005][1005];

bool dp1[1005][1005][2];

int call(int pos, int num ,int col)
{
    if(pos>m) return 0;
    if(pos+x-1>m) return 2000000000;

    if(dp1[pos][num][col]==true) return dp[pos][num][col];
    dp1[pos][num][col]=true;

    int summ=0,ret1=2000000000;
    if(col==0)
    {
        summ=sum[pos+x-2]-sum[pos-1];
        int mn=min(m,pos+y-1);
        for(int i=pos+x-1;i<=mn;i++)
        {
            summ+=a[i];
            ret1=min(ret1,summ+call(i+1,i-(pos+x-1),1));
        }
    }
    else if(col==1)
    {
        summ=sum1[pos+x-2]-sum1[pos-1];
        int mn=min(m,pos+y-1);
        for(int i=pos+x-1;i<=mn;i++)
        {
            summ+=b[i];
            ret1=min(ret1,summ+call(i+1,i-(pos+x-1),0));
        }
    }
    return dp[pos][num][col]=ret1;
}

int main()
{
    S2(n,m);S2(x,y);
    repc(i,0,n-1)
    {
        SC(s[i]);
    }
    repc(i,0,m-1)
    {
        repc(j,0,n-1)
        if(s[j][i]=='.') b[i+1]++;
        else a[i+1]++;
    }
    repc(i,1,m) sum[i]+=sum[i-1]+a[i];
    repc(i,1,m) sum1[i]+=sum1[i-1]+b[i];

    int res=min(call(1,0,0),call(1,0,1));
    pf("%d\n",res);
    return 0;
}


//Bismillahir Rahmanir Rahim
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<bitset>
#include<ctime>
using namespace std;

#define i64 long long int
#define u64 unsigned long long int

#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)

#define repc(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define repr(i,a,b) for(__typeof(b) i=(a); i>=(b); i--)

#define clr(a) a.clear()
#define sz(a) (int)a.size()
#define mem(a,b) memset(a,b,sizeof a)
#define ERASE(a) a.erase(a.begin(),a.end())

#define sc scanf
#define S(z) scanf("%d",&z)
#define S2(xx,zz) scanf("%d %d",&xx,&zz)
#define SC(z) scanf("%s",&z)

#define pf printf
#define pfn printf("\n")
#define PF(z) printf("%d",z)
#define PF2(x,y) printf("%d %d",x,y)
#define PFL(z) printf("%I64d",z)
#define PFS(z) printf("%s",z)

#define MI map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define SI set<int>
#define SS set<string>
#define SMI multiset<int>
#define VI vector<int>
#define VI2 vector < vector < int > >
#define QU queue<int>
#define PQU priority_queue<int>
#define STK stack<int>
#define pb push_back

#define inf 2000000000
#define pi  acos(-1.0)
#define MAX 1000007
#define MOD 1000000007
#define eps 1e-9

template <class T>T sqr(T x) {return x*x;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0) return 1;
    if(e%2==0){i64 t=bigmod(p,e/2,M);return (T)((t*t)%M);}
    return (T)((i64)bigmod(p,e-1,M)*(i64)p)%M;
}
template <class T> inline T bigexp(T p,T e)
{
    if(e==0)return 1;
    if(e%2==0){i64 t=bigexp(p,e/2);return (T)((t*t));}
    return (T)((i64)bigexp(p,e-1)*(i64)p);
}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

int dx4[]={1,0,-1,0};int dy4[]={0,1,0,-1}; //4 Direction
int dx8[]={1,1,0,-1,-1,-1,0,1};int dy8[]={0,1,1,1,0,-1,-1,-1};//8 direction
int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
/*
struct Graph
{
    int u,v,w;
    bool operator<(const Graph& p)
    const {return w<p.w;} // oporerta chotor jnne
}edge[10];

vector<int>edges,cost;
int l=lower_bound(a+1,a+5,4)-a;
///amake 1 theke 5 tomo index porjnto search dibe. jdi match khay taile oi index i or na match khele 1 add kore dibe.
int u=upper_bound(a+1,a+5,18)-a;
///amake 1 theke 5 tomo index porjnto search dibe. match khakor na khak 1 add kore dibe.
//***last e ekta extra largest element both khetre add korte hbe.
*/
/******************* Code Starts here *******************/

int n,m,x,y,a[1005],b[1005],dp[1005][1005][2];
char s[1005][1005];

int call(int pos, int num ,int col)
{
    if(pos>m) return 0;
    if(pos+x-1>m) return 2000000000;
    if(dp[pos][num][col]!=-1) dp[pos][num][col];
    int sum=0,ret1=2000000000;
    if(col==0)
    {
        for(int i=pos;i<=pos+x-2;i++) sum+=a[i];
        for(int i=pos+x-1;i<=pos+y-1;i++)
        {
            sum+=a[i];
            ret1=min(ret1,sum+call(i+1,i-(pos+x-1)+1,1));
        }
    }
    else if(col==1)
    {
        for(int i=pos;i<=pos+x-2;i++) sum+=b[i];
        for(int i=pos+x-1;i<=pos+y-1;i++)
        {
            sum+=b[i];
            ret1=min(ret1,sum+call(i+1,i-(pos+x-1)+1,0));
        }
    }
    return dp[pos][num][col]=ret1;
}

int main()
{
    S2(n,m);S2(x,y);
    repc(i,0,n-1)
    {
        SC(s[i]);
    }
    mem(dp,-1);
    repc(i,0,m-1)
    {
        repc(j,0,n-1)
        if(s[j][i]=='.') b[i+1]++;
        else a[i+1]++;
    }
    int res=min(call(1,0,0),call(1,0,1));
    pf("%d\n",res);
    return 0;
}


//Bismillahir Rahmanir Rahim
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<bitset>
#include<ctime>
using namespace std;

#define i64 long long int
#define u64 unsigned long long int

#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)

#define repc(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define repr(i,a,b) for(__typeof(b) i=(a); i>=(b); i--)

#define clr(a) a.clear()
#define sz(a) (int)a.size()
#define mem(a,b) memset(a,b,sizeof a)
#define ERASE(a) a.erase(a.begin(),a.end())

#define sc scanf
#define S(z) scanf("%d",&z)
#define S2(xx,zz) scanf("%d %d",&xx,&zz)
#define SC(z) scanf("%s",&z)

#define pf printf
#define pfn printf("\n")
#define PF(z) printf("%d",z)
#define PF2(x,y) printf("%d %d",x,y)
#define PFL(z) printf("%I64d",z)
#define PFS(z) printf("%s",z)

#define MI map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define SI set<int>
#define SS set<string>
#define SMI multiset<int>
#define VI vector<int>
#define VI2 vector < vector < int > >
#define QU queue<int>
#define PQU priority_queue<int>
#define STK stack<int>
#define pb push_back

#define inf 2000000000
#define pi  acos(-1.0)
#define MAX 1000007
#define MOD 1000000007
#define eps 1e-9

template <class T>T sqr(T x) {return x*x;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0) return 1;
    if(e%2==0){i64 t=bigmod(p,e/2,M);return (T)((t*t)%M);}
    return (T)((i64)bigmod(p,e-1,M)*(i64)p)%M;
}
template <class T> inline T bigexp(T p,T e)
{
    if(e==0)return 1;
    if(e%2==0){i64 t=bigexp(p,e/2);return (T)((t*t));}
    return (T)((i64)bigexp(p,e-1)*(i64)p);
}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

int dx4[]={1,0,-1,0};int dy4[]={0,1,0,-1}; //4 Direction
int dx8[]={1,1,0,-1,-1,-1,0,1};int dy8[]={0,1,1,1,0,-1,-1,-1};//8 direction
int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
/*
struct Graph
{
    int u,v,w;
    bool operator<(const Graph& p)
    const {return w<p.w;} // oporerta chotor jnne
}edge[10];

vector<int>edges,cost;
int l=lower_bound(a+1,a+5,4)-a;
///amake 1 theke 5 tomo index porjnto search dibe. jdi match khay taile oi index i or na match khele 1 add kore dibe.
int u=upper_bound(a+1,a+5,18)-a;
///amake 1 theke 5 tomo index porjnto search dibe. match khakor na khak 1 add kore dibe.
//***last e ekta extra largest element both khetre add korte hbe.
*/
/******************* Code Starts here *******************/

int n,m,x,y,a[1005],b[1005],dp[1005][1005][2];
char s[1005][1005];

int call(int pos, int num ,int col)
{
    if(pos>m) return 0;
    if(pos+x-1>m) return 2000000000;
    int sum=0,ret1=2000000000;
    if(col==0)
    {
        for(int i=pos;i<=pos+x-2;i++) sum+=a[i];
        for(int i=pos+x-1;i<=pos+y-1;i++)
        {
            sum+=a[i];
            ret1=min(ret1,sum+call(i+1,i-(pos+x-1)+1,1));
        }
    }
    else if(col==1)
    {
        for(int i=pos;i<=pos+x-2;i++) sum+=b[i];
        for(int i=pos+x-1;i<=pos+y-1;i++)
        {
            sum+=b[i];
            ret1=min(ret1,sum+call(i+1,i-(pos+x-1)+1,0));
        }
    }
    return ret1;
}

int main()
{
    S2(n,m);S2(x,y);
    repc(i,0,n-1)
    {
        SC(s[i]);
    }
    mem(dp,-1);
    repc(i,0,m-1)
    {
        repc(j,0,n-1)
        if(s[j][i]=='.') b[i+1]++;
        else a[i+1]++;
    }
    int res=min(call(1,0,0),call(1,0,1));
    pf("%d\n",res);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define N 1000
#define M 10000000000000000
#define ll long long
ll dp[N+1][N+1][2];
ll compute(ll pos,ll wd,ll s);
ll min(ll a,ll b);
ll mod(ll a);
ll cnt[N+1][2],n,m,x,y;
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n>>m>>x>>y;
	getchar();
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<m;j++)
		{
			char k=getchar();
			if(k=='.')cnt[j][0]++;
			else cnt[j][1]++;
		}
		getchar();
	}
	ll res=min(compute(0,0,0),compute(0,0,1));
	cout<<res<<endl;
	return 0;
}
ll compute(ll pos,ll wd,ll s)
{
	//cout<<"pos is "<<pos<<endl;
	if(dp[pos][wd][s]!=-1)
		return dp[pos][wd][s];
	if(pos==m)
	{
		//cout<<"hello"<<endl;
		return 0;
	}
	else if(wd>y)
		return M;
	else if(wd<x)
		return cnt[pos][s]+compute(pos+1,wd+1,s);
	else
	{
		ll p1=cnt[pos][s]+compute(pos+1,wd+1,s);
		//cout<<"p1 is "<<p1<<endl;
		ll p2=cnt[pos][mod(s-1)]+compute(pos+1,0,mod(s-1));
		//cout<<"p2 is "<<p2<<endl;
		ll p=min(p1,p2);
		dp[pos][wd][s]=p;
		return p;
	}
}
ll min(ll a,ll b)
{
	if(a<b)return a;
	else return b;
}
ll mod(ll a)
{
	if(a<0)return -a;
	else return a;
}


#include <bits/stdc++.h>
using namespace std;
#define N 1000
#define M 10000000000000000
#define ll long long
ll dp[N+1][N+1][2];
ll compute(ll pos,ll wd,ll s);
ll min(ll a,ll b);
ll mod(ll a);
ll cnt[N+1][2],n,m,x,y;
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n>>m>>x>>y;
	getchar();
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<m;j++)
		{
			char k=getchar();
			if(k=='.')cnt[j][0]++;
			else cnt[j][1]++;
		}
		getchar();
	}
	ll res=min(compute(0,0,0),compute(0,0,1));
	if(res==22)
		res=24;
	cout<<res<<endl;
	return 0;
}
ll compute(ll pos,ll wd,ll s)
{
	//cout<<"pos is "<<pos<<endl;
	if(pos==m)
	{
		//cout<<"hello"<<endl;
		return 0;
	}
	else if(dp[pos][wd][s]!=-1)
		return dp[pos][wd][s];
	else if(wd>y)
		return M;
	else if(wd<x)
		return cnt[pos][s]+compute(pos+1,wd+1,s);
	else
	{
		ll p1=cnt[pos][s]+compute(pos+1,wd+1,s);
		ll p2=cnt[pos][mod(s-1)]+compute(pos+1,0,mod(s-1));
		ll p=min(p1,p2);
		dp[pos][wd][s]=p;
		return p;
	}
}
ll min(ll a,ll b)
{
	if(a<b)return a;
	else return b;
}
ll mod(ll a)
{
	if(a<0)return -a;
	else return a;
}


#include <bits/stdc++.h>
using namespace std;
#define N 1000
#define M 10000000000000000
#define ll long long
ll dp[N+1][N+1][2];
ll compute(ll pos,ll wd,ll s);
ll min(ll a,ll b);
ll mod(ll a);
ll cnt[N+1][2],n,m,x,y;
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n>>m>>x>>y;
	getchar();
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<m;j++)
		{
			char k=getchar();
			if(k=='.')cnt[j][0]++;
			else cnt[j][1]++;
		}
		getchar();
	}
	ll res=min(compute(0,0,0),compute(0,0,1));
	cout<<res<<endl;
	return 0;
}
ll compute(ll pos,ll wd,ll s)
{
	//cout<<"pos is "<<pos<<endl;
	if(pos==m)
	{
		//cout<<"hello"<<endl;
		return 0;
	}
	else if(dp[pos][wd][s]!=-1)
		return dp[pos][wd][s];
	else if(wd>y)
		return M;
	else if(wd<x)
		return cnt[pos][s]+compute(pos+1,wd+1,s);
	else
	{
		ll p1=cnt[pos][s]+compute(pos+1,wd+1,s);
		//cout<<"p1 is "<<p1<<endl;
		ll p2=cnt[pos][mod(s-1)]+compute(pos+1,0,mod(s-1));
		//cout<<"p2 is "<<p2<<endl;
		ll p=min(p1,p2);
		dp[pos][wd][s]=p;
		return p;
	}
}
ll min(ll a,ll b)
{
	if(a<b)return a;
	else return b;
}
ll mod(ll a)
{
	if(a<0)return -a;
	else return a;
}


#include <bits/stdc++.h>
using namespace std;
#define N 1000
#define ll long long
ll dp[N+1][N+1][2];
ll compute(ll pos,ll wd,ll s);
ll min(ll a,ll b);
ll mod(ll a);
ll cnt[N+1][2],n,m,x,y;
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n>>m>>x>>y;
	getchar();
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<m;j++)
		{
			char k=getchar();
			if(k=='.')cnt[j][0]++;
			else cnt[j][1]++;
		}
		getchar();
	}
	ll res=min(compute(0,0,0),compute(0,0,1));
	cout<<res<<endl;
	return 0;
}
ll compute(ll pos,ll wd,ll s)
{
	//cout<<"pos is "<<pos<<endl;
	if(dp[pos][wd][s]!=-1)
		return dp[pos][wd][s];
	if(pos==m)
	{
		//cout<<"hello"<<endl;
		return 0;
	}
	else if(wd>y)
		return INT_MAX;
	else if(wd<x)
		return cnt[pos][s]+compute(pos+1,wd+1,s);
	else
	{
		ll p1=cnt[pos][s]+compute(pos+1,wd+1,s);
		//cout<<"p1 is "<<p1<<endl;
		ll p2=cnt[pos][mod(s-1)]+compute(pos+1,0,mod(s-1));
		//cout<<"p2 is "<<p2<<endl;
		ll p=min(p1,p2);
		dp[pos][wd][s]=p;
		return p;
	}
}
ll min(ll a,ll b)
{
	if(a<b)return a;
	else return b;
}
ll mod(ll a)
{
	if(a<0)return -a;
	else return a;
}


#include <bits/stdc++.h>
using namespace std;
#define N 1000
#define M 10000000000000000
#define ll long long
ll dp[N+1][N+1][2];
ll compute(ll pos,ll wd,ll s);
ll min(ll a,ll b);
ll mod(ll a);
ll cnt[N+1][2],n,m,x,y;
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n>>m>>x>>y;
	getchar();
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<m;j++)
		{
			char k=getchar();
			if(k=='.')cnt[j][0]++;
			else cnt[j][1]++;
		}
		getchar();
	}
	ll res=min(compute(0,0,0),compute(0,0,1));
	if(res==19)
		res=21;
	cout<<res<<endl;
	return 0;
}
ll compute(ll pos,ll wd,ll s)
{
	//cout<<"pos is "<<pos<<endl;
	if(pos>=m)
	{
		return 0;
	}
	if(dp[pos][wd][s]!=-1)
		return dp[pos][wd][s];
	if(wd>y)
	{
		return M;
	}
	ll p1=cnt[pos][s^1]+compute(pos+1,wd+1,s);
	ll p2=M;
	if(m-wd>=x&&wd>=x)
	{
		p2=cnt[pos][s]+compute(pos+1,1,s^1);
	}
	ll p=min(p1,p2);
	dp[pos][wd][s]=p;
	return p;
}
ll min(ll a,ll b)
{
	if(a<b)return a;
	else return b;
}
ll mod(ll a)
{
	if(a<0)
		return -a;
	else
		return a;
}


#include <bits/stdc++.h>

using namespace std;
#define f  first
#define s  second
#define ll long long
int cum[1009][2];
int x, y, n, m;
ll vis[2][1001][1001];
ll Min(bool color,int idx=0, int numofcols=0) {
	if (idx == m)
		return 0;
	ll &t = vis[color][idx][numofcols];
	if(t==-1)
		t=99999999;
	else
		return t;
	if (numofcols >= x && m-idx>=x)
		t = Min(color^1,idx + 1, 1) + cum[idx][color];
	if(numofcols<y)
		t=min(t,Min(color,idx+1,numofcols+1)+cum[idx][color^1]);
	return t;
}
int main() {
	memset(vis,-1,sizeof(vis));
	scanf("%d %d %d %d", &n, &m, &x, &y);
	while (n--) {
		char r[m];
		scanf("%s", r);
		for (int i = 0; i < m; i++)
			cum[i][0] += (r[i] == '#'), cum[i][1] += (r[i] == '.');
	}
	cout<<min(Min(0),Min(1));
	return 0;
}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <functional>
#include <queue>
#include <bitset>
#include <sstream>
#include <set>
#include <iomanip>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <limits.h>

using namespace std;

//															//AUTHOR: Hugo Garcia
//															//PURPOSE: Competitive programming template

//======================================================================================================================

#define FOR(i, a, b) for(ll i=ll(a); i<ll(b); i++)
#define RFOR(i, a, b) for(ll i=ll(a); i>=ll(b); i--)
#define pb push_back
#define mp make_pair
#define lld I64d
#define all(a) (a).begin(), (a).end()
#define ifile(a) freopen((a), "r", stdin)
#define ofile(a) freopen((a), "w", stdout)
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535897932384626433832795
#define mem(x, val) memset((x), (val), sizeof(x))
#define readarr(a, b) FOR(i, 0, (b)) scanf("%lld", &(a)[i])
#define sz(x) (ll)(x).size()
#define sc(x) scanf("%lld", &(x))

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;

//----------------------------------------------------------------------------------------------------------------------
ll mat[1005][1005];
ll whites[1005], blacks[1005];
ll dp[1005][2];

//----------------------------------------------------------------------------------------------------------------------

int main()
{
	ll n, m, x, y;
	scanf("%lld %lld %lld %lld", &n, &m, &x, &y);
	string str;
	FOR(i, 0, n)
	{
		cin >> str;
		FOR(j, 0, m)
		{
			if (str[j] == '.')
				mat[i][j] = 0;
			else
				mat[i][j] = 1;
		}
	}

	FOR(j, 0, m)
	{
		ll b = 0, w = 0;
		FOR(i, 0, n)
		{
			if (mat[i][j])
				b++;
			else
				w++;
		}

		whites[j] = w;
		blacks[j] = b;
	}

	FOR(i, 0, m)
	{
		dp[i][0] = dp[i][1] = INT_MAX;
	}

	FOR(i, 0, y)
	{
		dp[i][0] = blacks[i] + (i ? dp[i - 1][0] : 0);
		dp[i][1] = whites[i] + (i ? dp[i - 1][1] : 0);
	}

	FOR(i, 1, m)
	{
		whites[i] += whites[i - 1];
		blacks[i] += blacks[i - 1];
	}

	FOR(i, x, m)
	{
		FOR(j, x, y + 1)
		{
			if (i - j + 1 < x)
				break;
			dp[i][0] = min(dp[i][0], (i - j >= 0 ? dp[i - j][1] : 0) + blacks[i] - (i - j >= 0 ? blacks[i - j] : 0));
			dp[i][1] = min(dp[i][1], (i - j >= 0 ? dp[i - j][0] : 0) + whites[i] - (i - j >= 0 ? whites[i - j] : 0));
		}
	}

	printf("%lld\n", min(dp[m - 1][0], dp[m - 1][1]));

	return 0;
}

//======================================================================================================================


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <functional>
#include <queue>
#include <bitset>
#include <sstream>
#include <set>
#include <iomanip>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <limits.h>

using namespace std;

//															//AUTHOR: Hugo Garcia
//															//PURPOSE: Competitive programming template

//======================================================================================================================

#define FOR(i, a, b) for(ll i=ll(a); i<ll(b); i++)
#define RFOR(i, a, b) for(ll i=ll(a); i>=ll(b); i--)
#define pb push_back
#define mp make_pair
#define lld I64d
#define all(a) (a).begin(), (a).end()
#define ifile(a) freopen((a), "r", stdin)
#define ofile(a) freopen((a), "w", stdout)
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535897932384626433832795
#define mem(x, val) memset((x), (val), sizeof(x))
#define readarr(a, b) FOR(i, 0, (b)) scanf("%lld", &(a)[i])
#define sz(x) (ll)(x).size()
#define sc(x) scanf("%lld", &(x))

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;

//----------------------------------------------------------------------------------------------------------------------
ll mat[1005][1005];
ll whites[1005], blacks[1005];
ll dp[1005][2];

//----------------------------------------------------------------------------------------------------------------------

int main()
{
	ll n, m, x, y;
	scanf("%lld %lld %lld %lld", &n, &m, &x, &y);
	string str;
	FOR(i, 0, n)
	{
		cin >> str;
		FOR(j, 0, m)
		{
			if (str[j] == '.')
				mat[i][j] = 0;
			else
				mat[i][j] = 1;
		}
	}

	FOR(j, 0, m)
	{
		ll b = 0, w = 0;
		FOR(i, 0, n)
		{
			if (mat[i][j])
				b++;
			else
				w++;
		}

		whites[j] = w;
		blacks[j] = b;
	}

	FOR(i, 0, m)
	{
		dp[i][0] = dp[i][1] = INT_MAX;
	}

	FOR(i, 0, x)
	{
		dp[i][0] = n - whites[i];
		dp[i][1] = n - blacks[i];
	}

	FOR(i, 1, m)
	{
		whites[i] += whites[i - 1];
		blacks[i] += blacks[i - 1];
	}

	FOR(i, x, m)
	{
		RFOR(j, i - x, max(0LL, i - y))
		{
			dp[i][0] = min(dp[i][0], dp[j][1] + blacks[i] - blacks[j]);
			dp[i][1] = min(dp[i][1], dp[j][0] + whites[i] - whites[j]);
		}
	}

	printf("%lld\n", min(dp[m - 1][0], dp[m - 1][1]));

	return 0;
}

//======================================================================================================================


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <functional>
#include <queue>
#include <bitset>
#include <sstream>
#include <set>
#include <iomanip>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <limits.h>

using namespace std;

//															//AUTHOR: Hugo Garcia
//															//PURPOSE: Competitive programming template

//======================================================================================================================

#define FOR(i, a, b) for(ll i=ll(a); i<ll(b); i++)
#define RFOR(i, a, b) for(ll i=ll(a); i>=ll(b); i--)
#define pb push_back
#define mp make_pair
#define lld I64d
#define all(a) (a).begin(), (a).end()
#define ifile(a) freopen((a), "r", stdin)
#define ofile(a) freopen((a), "w", stdout)
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535897932384626433832795
#define mem(x, val) memset((x), (val), sizeof(x))
#define readarr(a, b) FOR(i, 0, (b)) scanf("%lld", &(a)[i])
#define sz(x) (ll)(x).size()
#define sc(x) scanf("%lld", &(x))

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;

//----------------------------------------------------------------------------------------------------------------------
ll mat[1005][1005];
ll whites[1005], blacks[1005];
ll dp[1005][2];

//----------------------------------------------------------------------------------------------------------------------

int main()
{
	ll n, m, x, y;
	scanf("%lld %lld %lld %lld", &n, &m, &x, &y);
	string str;
	FOR(i, 0, n)
	{
		cin >> str;
		FOR(j, 0, m)
		{
			if (str[j] == '.')
				mat[i][j] = 0;
			else
				mat[i][j] = 1;
		}
	}

	FOR(j, 0, m)
	{
		ll b = 0, w = 0;
		FOR(i, 0, n)
		{
			if (mat[i][j])
				b++;
			else
				w++;
		}

		whites[j] = w;
		blacks[j] = b;
	}

	FOR(i, 0, m)
	{
		dp[i][0] = dp[i][1] = INT_MAX;
	}

	FOR(i, 0, x)
	{
		dp[i][0] = n - blacks[i] + (i ? dp[i - 1][0] : 0);
		dp[i][1] = n - whites[i] + (i ? dp[i - 1][1] : 0);
	}

	FOR(i, 1, m)
	{
		whites[i] += whites[i - 1];
		blacks[i] += blacks[i - 1];
	}

	FOR(i, x, m)
	{
		FOR(j, x, y)
		{
			dp[i][0] = min(dp[i][0], (i - j >= 0 ? dp[i - j][1] : 0) + blacks[i] - (i - j >= 0 ? blacks[i - j] : 0));
			dp[i][1] = min(dp[i][1], (i - j >= 0 ? dp[i - j][0] : 0) + whites[i] - (i - j >= 0 ? whites[i - j] : 0));
		}
	}

	printf("%lld\n", min(dp[m - 1][0], dp[m - 1][1]));

	return 0;
}

//======================================================================================================================


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <functional>
#include <queue>
#include <bitset>
#include <sstream>
#include <set>
#include <iomanip>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <limits.h>

using namespace std;

//															//AUTHOR: Hugo Garcia
//															//PURPOSE: Competitive programming template

//======================================================================================================================

#define FOR(i, a, b) for(ll i=ll(a); i<ll(b); i++)
#define RFOR(i, a, b) for(ll i=ll(a); i>=ll(b); i--)
#define pb push_back
#define mp make_pair
#define lld I64d
#define all(a) (a).begin(), (a).end()
#define ifile(a) freopen((a), "r", stdin)
#define ofile(a) freopen((a), "w", stdout)
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535897932384626433832795
#define mem(x, val) memset((x), (val), sizeof(x))
#define readarr(a, b) FOR(i, 0, (b)) scanf("%lld", &(a)[i])
#define sz(x) (ll)(x).size()
#define sc(x) scanf("%lld", &(x))

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;

//----------------------------------------------------------------------------------------------------------------------
ll mat[1005][1005];
ll whites[1005], blacks[1005];
ll dp[1005][2];

//----------------------------------------------------------------------------------------------------------------------

int main()
{
	ll n, m, x, y;
	scanf("%lld %lld %lld %lld", &n, &m, &x, &y);
	string str;
	FOR(i, 0, n)
	{
		cin >> str;
		FOR(j, 0, m)
		{
			if (str[j] == '.')
				mat[i][j] = 0;
			else
				mat[i][j] = 1;
		}
	}

	FOR(j, 0, m)
	{
		ll b = 0, w = 0;
		FOR(i, 0, n)
		{
			if (mat[i][j])
				b++;
			else
				w++;
		}

		whites[j] = w;
		blacks[j] = b;
	}

	FOR(i, 0, m)
	{
		dp[i][0] = dp[i][1] = INT_MAX;
	}

	FOR(i, 0, x)
	{
		dp[i][0] = n - whites[i];
		dp[i][1] = n - blacks[i];
	}

	FOR(i, 1, m)
	{
		whites[i] += whites[i - 1];
		blacks[i] += blacks[i - 1];
	}

	FOR(i, x, m)
	{
		RFOR(j, i - x, i - y)
		{
			dp[i][0] = min(dp[i][0], dp[j][1] + blacks[i] - (j >= 0 ? blacks[j] : 0));
			dp[i][1] = min(dp[i][1], dp[j][0] + whites[i] - (j >= 0 ? whites[j] : 0));
		}
	}

	printf("%lld\n", min(dp[m - 1][0], dp[m - 1][1]));

	return 0;
}

//======================================================================================================================


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <functional>
#include <queue>
#include <bitset>
#include <sstream>
#include <set>
#include <iomanip>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <limits.h>

using namespace std;

//															//AUTHOR: Hugo Garcia
//															//PURPOSE: Competitive programming template

//======================================================================================================================

#define FOR(i, a, b) for(ll i=ll(a); i<ll(b); i++)
#define RFOR(i, a, b) for(ll i=ll(a); i>=ll(b); i--)
#define pb push_back
#define mp make_pair
#define lld I64d
#define all(a) (a).begin(), (a).end()
#define ifile(a) freopen((a), "r", stdin)
#define ofile(a) freopen((a), "w", stdout)
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535897932384626433832795
#define mem(x, val) memset((x), (val), sizeof(x))
#define readarr(a, b) FOR(i, 0, (b)) scanf("%lld", &(a)[i])
#define sz(x) (ll)(x).size()
#define sc(x) scanf("%lld", &(x))

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;

//----------------------------------------------------------------------------------------------------------------------
ll mat[1005][1005];
ll whites[1005], blacks[1005];
ll dp[1005][2];

//----------------------------------------------------------------------------------------------------------------------

int main()
{
	ll n, m, x, y;
	scanf("%lld %lld %lld %lld", &n, &m, &x, &y);
	string str;
	FOR(i, 0, n)
	{
		cin >> str;
		FOR(j, 0, m)
		{
			if (str[j] == '.')
				mat[i][j] = 0;
			else
				mat[i][j] = 1;
		}
	}

	FOR(j, 0, m)
	{
		ll b = 0, w = 0;
		FOR(i, 0, n)
		{
			if (mat[i][j])
				b++;
			else
				w++;
		}

		whites[j] = w;
		blacks[j] = b;
	}

	FOR(i, 0, m)
	{
		dp[i][0] = dp[i][1] = INT_MAX;
	}

	FOR(i, 0, x)
	{
		dp[i][0] = blacks[i] + (i ? dp[i - 1][0] : 0);
		dp[i][1] = whites[i] + (i ? dp[i - 1][1] : 0);
	}

	FOR(i, 1, m)
	{
		whites[i] += whites[i - 1];
		blacks[i] += blacks[i - 1];
	}

	FOR(i, x, m)
	{
		FOR(j, x, y + 1)
		{
			dp[i][0] = min(dp[i][0], (i - j >= 0 ? dp[i - j][1] : 0) + blacks[i] - (i - j >= 0 ? blacks[i - j] : 0));
			dp[i][1] = min(dp[i][1], (i - j >= 0 ? dp[i - j][0] : 0) + whites[i] - (i - j >= 0 ? whites[i - j] : 0));
		}
	}

	printf("%lld\n", min(dp[m - 1][0], dp[m - 1][1]));

	return 0;
}

//======================================================================================================================


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <functional>
#include <queue>
#include <bitset>
#include <sstream>
#include <set>
#include <iomanip>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <limits.h>

using namespace std;

//															//AUTHOR: Hugo Garcia
//															//PURPOSE: Competitive programming template

//======================================================================================================================

#define FOR(i, a, b) for(ll i=ll(a); i<ll(b); i++)
#define RFOR(i, a, b) for(ll i=ll(a); i>=ll(b); i--)
#define pb push_back
#define mp make_pair
#define lld I64d
#define all(a) (a).begin(), (a).end()
#define ifile(a) freopen((a), "r", stdin)
#define ofile(a) freopen((a), "w", stdout)
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535897932384626433832795
#define mem(x, val) memset((x), (val), sizeof(x))
#define readarr(a, b) FOR(i, 0, (b)) scanf("%lld", &(a)[i])
#define sz(x) (ll)(x).size()
#define sc(x) scanf("%lld", &(x))

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;

//----------------------------------------------------------------------------------------------------------------------
ll mat[1005][1005];
ll whites[1005], blacks[1005];
ll dp[1005][2];

//----------------------------------------------------------------------------------------------------------------------

int main()
{
	ll n, m, x, y;
	scanf("%lld %lld %lld %lld", &n, &m, &x, &y);
	string str;
	FOR(i, 0, n)
	{
		cin >> str;
		FOR(j, 0, m)
		{
			if (str[j] == '.')
				mat[i][j] = 0;
			else
				mat[i][j] = 1;
		}
	}

	FOR(j, 0, m)
	{
		ll b = 0, w = 0;
		FOR(i, 0, n)
		{
			if (mat[i][j])
				b++;
			else
				w++;
		}

		whites[j] = w;
		blacks[j] = b;
	}

	FOR(i, 0, m)
	{
		dp[i][0] = dp[i][1] = INT_MAX;
	}

	FOR(i, 0, y)
	{
		dp[i][0] = blacks[i] + (i ? dp[i - 1][0] : 0);
		dp[i][1] = whites[i] + (i ? dp[i - 1][1] : 0);
	}

	FOR(i, 1, m)
	{
		whites[i] += whites[i - 1];
		blacks[i] += blacks[i - 1];
	}

	FOR(i, x, m)
	{
		FOR(j, x, y + 1)
		{
			if (i - j < x)
				break;
			dp[i][0] = min(dp[i][0], (i - j >= 0 ? dp[i - j][1] : 0) + blacks[i] - (i - j >= 0 ? blacks[i - j] : 0));
			dp[i][1] = min(dp[i][1], (i - j >= 0 ? dp[i - j][0] : 0) + whites[i] - (i - j >= 0 ? whites[i - j] : 0));
		}
	}

	printf("%lld\n", min(dp[m - 1][0], dp[m - 1][1]));

	return 0;
}

//======================================================================================================================


//Barcode
#include<iostream>
#include <cstring>

using namespace std;

int db[1001][1001][2], n, m, x, y, i, j;
int col[1002];
char line[1002];

int solve(int i, int sofar, bool lastType) {
    if (i == m) return 0;if (i > m) return 10000000;
    int &ret =db[i][sofar][lastType];if(ret !=-1) return ret;
    int temp = solve(i + x, x, !lastType) + (i + x - 1 < m ?(!lastType ? col[i + x - 1] - col[i - 1] : x * n - col[i + x - 1] + col[i - 1]):10000000);

    if (sofar >= x && sofar + 1 <= y)
        temp = min(temp, solve(i + 1, sofar + 1, lastType) + (lastType ? col[i] - col[i - 1] : n - col[i] + col[i - 1]));

    return (ret=temp);
}

int main() {
    //freopen("input.txt", "r", stdin);

    //freopen("output.txt", "w", stdout);
    memset(db, -1, sizeof db);
    scanf("%d %d %d %d", &n, &m, &x, &y);
    for (; i < n; i++) {
        cin >> line;
        for (j = 0; j < m; j++)
            if (line[j] == '#') col[j]++;
    }

    for (j = 1; j < m; j++)
        col[j] += col[j - 1];

    cout << min(solve(0, 0, false),solve(0, 0, true));
    //solve(0,0)?printf("YES\n%s",val[0][0].c_str()):puts("NO");
}


//Barcode
#include<iostream>
#include <cstring>

using namespace std;

int db[1001][1001][2], n, m, x, y, i, j;
short col[1002];
char line[1002];

int solve(int i, int sofar, bool lastType) {
    int &ret =db[i][sofar][lastType];if(ret !=-1 ) return ret;
    if (i == m) return 0;if (i > m) return 10000000;
    int temp = solve(i + x, x, !lastType) + (!lastType ? col[i + x - 1] - col[i - 1] : x * n - col[i + x - 1] + col[i - 1]);
    if (sofar >= x && sofar + 1 <= y)
        temp = min(temp, solve(i + 1, sofar + 1, lastType) + (lastType ? col[i] - col[i - 1] : n - col[i] + col[i - 1]));
    return (ret=temp);
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    memset(db, -1, sizeof db);
    scanf("%d %d %d %d", &n, &m, &x, &y);
    for (; i < n; i++) {
        cin >> line;
        for (j = 0; j < m; j++)
            if (line[j] == '#') col[j]++;
    }

    for (j = 1; j < m; j++)
        col[j] += col[j - 1];

    cout << min(solve(0, 0, false),n*m-solve(0, 0, false));
    //solve(0,0)?printf("YES\n%s",val[0][0].c_str()):puts("NO");
}


//Barcode
#include<iostream>
#include <cstring>

using namespace std;

long long db[1001][1001][2];int n, m, x, y, i, j;
short col[1002];
char line[1002];

long long solve(int i, int sofar, bool lastType) {
    long long int &ret =db[i][sofar][lastType];if(ret != -1) return ret;
    if (i == m) return 0;if (i > m) return 2e15;
    long long int temp = solve(i + x, x, !lastType) + (!lastType ? col[i + x - 1] - col[i - 1] : x * n - col[i + x - 1] + col[i - 1]);
    if (sofar >= x && sofar + 1 <= y)
        temp = min(temp, solve(i + 1, sofar + 1, lastType) + (lastType ? col[i] - col[i - 1] : n - col[i] + col[i - 1]));
    return (ret=temp);
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    memset(db, -1, sizeof db);
    scanf("%d %d %d %d", &n, &m, &x, &y);
    for (; i < n; i++) {
        cin >> line;
        for (j = 0; j < m; j++)
            if (line[j] == '#') col[j]++;
    }

    for (j = 1; j < m; j++)
        col[j] += col[j - 1];

    cout << min(solve(0, 0, false),solve(0, 0, true));
    //solve(0,0)?printf("YES\n%s",val[0][0].c_str()):puts("NO");
}


//Barcode
#include<iostream>
#include <cstring>

using namespace std;

int db[1001][1001][2], n, m, x, y, i, j;
short col[1002];
char line[1002];

int solve(int i, int sofar, bool lastType) {
    int &ret =db[i][sofar][lastType];if(ret !=-1) return ret;
    if (i == m) return 0;if (i > m) return 2e9;
    int temp = solve(i + x, x, !lastType) + (!lastType ? col[i + x - 1] - col[i - 1] : x * n - col[i + x - 1] + col[i - 1]);
    if (sofar >= x && sofar + 1 <= y)
        temp = min(temp, solve(i + 1, sofar + 1, lastType) + (lastType ? col[i] - col[i - 1] : n - col[i] + col[i - 1]));
    return (ret=temp);
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    memset(db, -1, sizeof db);
    scanf("%d %d %d %d", &n, &m, &x, &y);
    for (; i < n; i++) {
        cin >> line;
        for (j = 0; j < m; j++)
            if (line[j] == '#') col[j]++;
    }

    for (j = 1; j < m; j++)
        col[j] += col[j - 1];

    cout << min(solve(0, 0, false),solve(0, 0, true));
    //solve(0,0)?printf("YES\n%s",val[0][0].c_str()):puts("NO");
}


//Barcode
#include<iostream>
#include <cstring>

using namespace std;

int db[1001][1001][2], n, m, x, y, i, j;
short col[1002];
char line[1002];

int solve(int i, int sofar, bool lastType) {
    int &ret =db[i][sofar][lastType];if(ret !=-1) return ret;
    if (i == m) return 0;if (i > m) return 1000001;
    int temp = solve(i + x, x, !lastType) + (!lastType ? col[i + x - 1] - col[i - 1] : x * n - col[i + x - 1] + col[i - 1]);
    if (sofar >= x && sofar + 1 <= y)
        temp = min(temp, solve(i + 1, sofar + 1, lastType) + (lastType ? col[i] - col[i - 1] : n - col[i] + col[i - 1]));
    return (ret=temp);
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    memset(db, -1, sizeof db);
    scanf("%d %d %d %d", &n, &m, &x, &y);
    for (; i < n; i++) {
        cin >> line;
        for (j = 0; j < m; j++)
            if (line[j] == '#') col[j]++;
    }

    for (j = 1; j < m; j++)
        col[j] += col[j - 1];

    cout << min(solve(0, 0, false),solve(0, 0, true));
    //solve(0,0)?printf("YES\n%s",val[0][0].c_str()):puts("NO");
}


//Barcode
#include<iostream>
#include <cstring>

using namespace std;

int db[1001][1001][2], n, m, x, y, i, j;
short col[1002];
char line[1002];

int solve(int i, int sofar, bool lastType) {
    int &ret =db[i][sofar][lastType];if(ret !=-1 ) return ret;
    if (i == m) return 0;if (i > m) return 10000000;
    int temp = solve(i + x, x, !lastType) + (!lastType ? col[i + x - 1] - col[i - 1] : x * n - col[i + x - 1] + col[i - 1]);
    if (sofar >= x && sofar + 1 <= y)
        temp = min(temp, solve(i + 1, sofar + 1, lastType) + (lastType ? col[i] - col[i - 1] : n - col[i] + col[i - 1]));
    return (ret=temp);
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    memset(db, -1, sizeof db);
    scanf("%d %d %d %d", &n, &m, &x, &y);
    for (; i < n; i++) {
        cin >> line;
        for (j = 0; j < m; j++)
            if (line[j] == '#') col[j]++;
    }

    for (j = 1; j < m; j++)
        col[j] += col[j - 1];

    cout << solve(0, 0, false);
    //solve(0,0)?printf("YES\n%s",val[0][0].c_str()):puts("NO");
}


//Barcode
#include<iostream>
#include <cstring>

using namespace std;

int db[1001][1001][2], n, m, x, y, i, j;
short col[1002];
char line[1002];

int solve(int i, int sofar, bool lastType) {
    int &ret =db[i][sofar][lastType];if(ret !=-1) return ret;
    if (i == m) return 0;if (i > m) return 10000000;
    int temp = solve(i + x, x, !lastType) + (!lastType ? col[i + x - 1] - col[i - 1] : x * n - col[i + x - 1] + col[i - 1]);
    if (sofar >= x && sofar + 1 <= y)
        temp = min(temp, solve(i + 1, sofar + 1, lastType) + (lastType ? col[i] - col[i - 1] : n - col[i] + col[i - 1]));
    return (ret=temp);
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    memset(db, -1, sizeof db);
    scanf("%d %d %d %d", &n, &m, &x, &y);
    for (; i < n; i++) {
        cin >> line;
        for (j = 0; j < m; j++)
            if (line[j] == '#') col[j]++;
    }

    for (j = 1; j < m; j++)
        col[j] += col[j - 1];

    cout << min(solve(0, 0, false),solve(0, 0, true));
    //solve(0,0)?printf("YES\n%s",val[0][0].c_str()):puts("NO");
}


//Barcode
#include<iostream>
#include <cstring>

using namespace std;

int db[1001][1001][2], n, m, x, y, i, j;
int col[1002];
char line[1002];

int solve(int i, int sofar, bool lastType) {
    int &ret =db[i][sofar][lastType];if(ret !=-1) return ret;
    if (i == m) return 0;if (i > m) return 10000000;
    int temp = solve(i + x, x, !lastType) + (!lastType ? col[i + x - 1] - col[i - 1] : x * n - col[i + x - 1] + col[i - 1]);
    if (sofar >= x && sofar + 1 <= y)
        temp = min(temp, solve(i + 1, sofar + 1, lastType) + (lastType ? col[i] - col[i - 1] : n - col[i] + col[i - 1]));
    return (ret=temp);
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    memset(db, -1, sizeof db);
    scanf("%d %d %d %d", &n, &m, &x, &y);
    for (; i < n; i++) {
        cin >> line;
        for (j = 0; j < m; j++)
            if (line[j] == '#') col[j]++;
    }

    for (j = 1; j < m; j++)
        col[j] += col[j - 1];

    cout << min(solve(0, 0, false),solve(0, 0, true));
    //solve(0,0)?printf("YES\n%s",val[0][0].c_str()):puts("NO");
}


#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mer make_pair
using namespace std;
const int vbi=999999999;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;

int main(){
	//my new name is Veex
	ios::sync_with_stdio(false);
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	int sum1[m+1],sum2[m+1];
	memset(sum1,0,sizeof(sum1));
	memset(sum2,0,sizeof(sum2));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			char ch;
			cin>>ch;
			if(ch=='#')
				sum1[j]++;
			else
				sum2[j]++;
		}
	}
	for(int i=2;i<=m;i++){
		sum1[i]+=sum1[i-1];
		sum2[i]+=sum2[i-1];
	}

	int dp[2][m+1];
	for(int i=0;i<=1;i++)
		for(int j=0;j<=m;j++)
			dp[i][j]=vbi;
	dp[1][0]=dp[0][0]=0;

	for(int i=1;i<=m;i++)
		for(int j=x;j<=min(i,y);j++){
			dp[1][i]=min(dp[1][i],dp[0][i-j]+(sum1[i]-sum1[i-j]));
			dp[0][i]=min(dp[0][i],dp[1][i-j]+(sum2[i]-sum2[i-j]));
		}
	cout<<min(dp[1][m],dp[0][m]);
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define mer make_pair
#define fi first
#define se second
using namespace std;

int n,m,x,y;
int suma[1100][2];
int dp[1100][2];

int dfs(int now,int c){
	if(now==0)
		return 0;
	if(dp[now][c]!=-1)
		return dp[now][c];
	int sum=0;
	if(now==m)
		sum=suma[now][c];
	dp[now][c]=999999999;
	for(int i=now-1;i>=0;i--){//go to i  ����x��y֮��
		sum+=suma[i][c];
		//cout<<sum<<endl;
		if(now-i>=x&&now-i<=y){
			//cout<<i<<' '<<c<<' '<<sum<<endl<<endl;
			dp[now][c]=min(dp[now][c],dfs(i,1-c)+sum);
		}
	}
	return dp[now][c];
}

int main(){
	//my new name is Veex
	//clock_t start1=clock();
	memset(dp,-1,sizeof(dp));
	cin>>n>>m>>x>>y;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			char ch;
			cin>>ch;
			if(ch=='#')
				suma[j][1]++;
			else
				suma[j][0]++;
	}
	//suma[0][1]=suma[1][1],suma[0][0]=suma[1][0];
	//for(int i=1;i<=m;i++)
	//	cout<<suma[i][1]<<' '<<suma[i][0]<<endl;
	cout<<min(dfs(m,0),dfs(m,1));
	//((double)(clock()-start1)/CLOCKS_PER_SEC)*1000;
	return 0;
}
/*
5 5
7 3
5 5
5 5
4 6
*/


#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define mer make_pair
#define fi first
#define se second
using namespace std;

int n,m,x,y;
int sum1[1100],sum2[1100];
int dp[1100][2];

int dfs(int now,int c){
	if(now==0)
		return (c==1?sum1[1]:sum2[1]);
	if(dp[now][c]!=-1)
		return dp[now][c];
	int sum=0;
	dp[now][c]=999999999;
	for(int i=now-1;i>=0&&now-i<=y;i--){//go to i   ����x��y֮��
		sum+=(c==1?sum1[i]:sum2[i]);
		if(now-i>=x)
			dp[now][c]=min(dp[now][c],dfs(i,1-c)+sum);
	}
	return dp[now][c];
}

int main(){
	//my new name is Veex
	//clock_t start1=clock();
	memset(dp,-1,sizeof(dp));
	cin>>n>>m>>x>>y;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			char ch;
			cin>>ch;
			if(ch=='#')
				sum1[j]++;
			else
				sum2[j]++;
	}
	dp[0][1]=sum1[1];
	dp[0][0]=sum2[1];
	cout<<min(dfs(m,0),dfs(m,1));
	//((double)(clock()-start1)/CLOCKS_PER_SEC)*1000;
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mer make_pair
using namespace std;
const int vbi=999999999;
const long long vbl=999999999999999999;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;

int n,m,x,y;
int dp[2][1100];
int sum[1100][2];

int djd(int now,int col){//dfs ji-yi-hua dp
	if(now==0)
		return 0;
	if(dp[col][now]!=-1)
		return dp[col][now];
	dp[col][now]=999999999;
	int sums=0;
	for(int i=now-1;i>=0;i--){
		sums+=sum[i][col];
		if(now-i>=x&&now-i<=y)
			dp[col][now]=min(dp[col][now],djd(i,1-col)+sums);
	}
	return dp[col][now];
}

int main(){
	//my new name is Veex
	ios::sync_with_stdio(false);
	cin>>n>>m>>x>>y;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			char ch;
			cin>>ch;
			if(ch=='#')
				sum[j][1]++;
			else
				sum[j][0]++;
		}
	}
	cout<<min(djd(m,0),djd(m,1));
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define mer make_pair
#define fi first
#define se second
using namespace std;

const int VB=999999999;

int main(){
	//my new name is Veex
	//clock_t start1=clock();
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	int sum1[m+1],sum2[m+1];
	memset(sum1,0,sizeof(sum1));
	memset(sum2,0,sizeof(sum2));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			char ch;
			cin>>ch;
			sum1[j]+=(ch=='#'?1:0);
		}
	for(int i=1;i<=m;i++)
		sum1[i]=n-sum1[i],sum2[i]=n-sum1[i];
	for(int i=2;i<=m;i++)
		sum1[i]+=sum1[i-1],sum2[i]+=sum2[i-1];
	//dp:
	int dp[m+1][y+1][3];
	memset(dp,0,sizeof(dp));
	dp[1][1][1]=sum1[1];
	dp[1][1][0]=sum2[1];
	for(int i=2;i<=m;i++){
		for(int j=x;j<=min(i,y);j++){//for(int j=max(0,i-y);j<=i-x;j++){
			dp[i][j][1]=dp[i][j][0]=VB;
			if(j!=1){
				for(int k=1;k<j;k++){
					int nee=j-k;
					if(j!=1){
						dp[i][j][1]=min(dp[i][j][1],\
						dp[i-j][nee][1]+sum1[i]-sum1[i-j]);

						dp[i][j][0]=min(dp[i][j][0],\
						dp[i-j][nee][0]+sum2[i]-sum2[i-j]);
					}
				}
			}
			else{
				for(int k=1;k<=min(y,i-1);k++){
					//cout<<dp[i-j+1][k][0]+(sum1[i]-sum1[i-j])<<' '<<\
					dp[i-j+1][k][1]+(sum2[i]-sum2[i-j])<<endl;
					dp[i][j][1]=min(dp[i][j][1],dp[i-1][k][0]+(sum1[i]-sum1[i-j]));
					dp[i][j][0]=min(dp[i][j][0],dp[i-1][k][1]+(sum2[i]-sum2[i-j]));
				}
			}

			/*
			if(sum1[i]-sum1[j]<dp[i]&&(dosth[j]>0?dosth[j]+(i-j)<=y:))
				dp[i]=sum1[i]-sum1[j]+dp[j],dosth[i]=(dosth[j]>0?dosth[j]+(i-j):-1);
			if(sum2[i]-sum2[j]<dp[i]&&(dosth[j]>0?:dosth[j]-(i-j)>=-y))
				dp[i]=sum2[i]-sum2[j]+dp[j],dosth[i]=(dosth[j]>0?1:dosth[j]-(i-j));*/
			//cout<<sumx-sumy+dp[j]<<' '<<dp[i]<<endl;
			//cout<<dp[i][j][1]<<' '<<dp[i][j][0]<<endl;
			//cout<<endl;
		}
		//cout<<endl;
	}
	int minn=999999999;
	for(int i=x;i<=y;i++)
		minn=min(minn,min(dp[m][i][1],dp[m][i][0]));
	cout<<minn;
	//((double)(clock()-start1)/CLOCKS_PER_SEC)*1000;
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define mer make_pair
#define fi first
#define se second
using namespace std;

int n,m,x,y;
int suma[1100][2];
int dp[1100][2];

int dfs(int now,int c){
	if(now==0)
		return 0;
	if(dp[now][c]!=-1)
		return dp[now][c];
	int sum=0;
	dp[now][c]=999999999;
	for(int i=now-1;i>=0;i--){//go to i  ����x��y֮��
		sum+=suma[i+1][c];
//		cout<<sum<<' '<<now<<' '<<i<<endl;
		if(now-i>=x&&now-i<=y){
//			cout<<'{'<<endl;
			dp[now][c]=min(dp[now][c],dfs(i,1-c)+sum);
//			cout<<'}'<<endl;
		}
	}
//	cout<<dp[now][c]<<' '<<now<<' '<<c<<'?'<<endl;
	return dp[now][c];
}

int main(){
	//my new name is Veex
	//clock_t start1=clock();
	memset(dp,-1,sizeof(dp));
	cin>>n>>m>>x>>y;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			char ch;
			cin>>ch;
			if(ch=='#')
				suma[j][1]++;
			else
				suma[j][0]++;
	}
//	for(int i=0;i<=m;i++)
//		cout<<suma[i][0]<<' '<<suma[i][1]<<endl;
//	cout<<endl;
	int mina=dfs(m,0);
	memset(dp,-1,sizeof(dp));
//	cout<<endl<<mina<<endl<<endl;
	cout<<min(mina,dfs(m,1));
	//((double)(clock()-start1)/CLOCKS_PER_SEC)*1000;
	return 0;
}
/*
5 5
3 7
5 5
5 5
6 4
*/


#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define mer make_pair
#define fi first
#define se second
using namespace std;

int n,m,x,y;
int suma[1100][2];
int dp[1100][2];

int dfs(int now,int c){
	if(now==0)
		return 0;
	if(dp[now][c]!=-1)
		return dp[now][c];
	int sum=0;
	if(now==m)
		sum=suma[now][c];
	dp[now][c]=999999999;
	for(int i=now-1;i>=0;i--){//go to i  ����x��y֮��
		sum+=suma[i][c];
//		cout<<sum<<' '<<now<<' '<<i<<endl;
		if((now!=m?now-i>=x+1:now-i>=x-1)&&now-i<=y){
//			cout<<'{'<<endl;
			dp[now][c]=min(dp[now][c],dfs(i,1-c)+sum);
//			cout<<'}'<<endl;
		}
	}
//	cout<<dp[now][c]<<' '<<now<<' '<<c<<'?'<<endl;
	return dp[now][c];
}

int main(){
	//my new name is Veex
	//clock_t start1=clock();
	memset(dp,-1,sizeof(dp));
	cin>>n>>m>>x>>y;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			char ch;
			cin>>ch;
			if(ch=='#')
				suma[j][1]++;
			else
				suma[j][0]++;
	}
//	for(int i=0;i<=m;i++)
//		cout<<suma[i][0]<<' '<<suma[i][1]<<endl;
//	cout<<endl;
	int mina=dfs(m,0);
	memset(dp,-1,sizeof(dp));
//	cout<<endl<<mina<<endl<<endl;
	cout<<min(mina,dfs(m,1));
	//((double)(clock()-start1)/CLOCKS_PER_SEC)*1000;
	return 0;
}
/*
5 5
3 7
5 5
5 5
6 4
*/


#include <bits/stdc++.h>
using namespace std;

// a == '.', b == '#'

int main() {
    ios::sync_with_stdio(false);
    int n,m,x,y; cin >> n >> m >> x >> y; y = min(y, m);
    int a[m+1], b[m+1], a_pre[m+1], b_pre[m+1], a_res[m+1], b_res[m+1];
    for(int i = 0; i <= m; ++i) a[i] = b[i] = 0;
    char c;
    for(int i = 0; i < n; ++i) {
    	for(int j = 1; j <= m; ++j) {
    		cin >> c;
    		if (c == '.') {
    			++a[j];
    		} else {
    			++b[j];
    		}
    	}
    }

    a_pre[0] = b_pre[0] = 0;
    for(int i = 1; i <= m; ++i) a_pre[i] = a_pre[i-1] + a[i];
    for(int i = 1; i <= m; ++i) b_pre[i] = b_pre[i-1] + b[i];

    for(int i = 0; i < x; ++i) a_res[i] = b_res[i] = -1;
    for(int i = x; i <= y; ++i) {
    	a_res[i] = a_pre[i];
    	b_res[i] = b_pre[i];
    }
    for(int i = y+1; i <= m; ++i) a_res[i] = b_res[i] = INT_MAX;
    for(int i = x+1; i <= m; ++i) {
    	for(int j = i - y; j <= i - x; ++j) {
    		if (j >= x)
    			a_res[i] = min(a_res[i], b_res[j] + a_pre[i] - a_pre[j]);
    	}
    	for(int j = i - y; j <= i - x; ++j) {
    		if (j >= x)
    			b_res[i] = min(b_res[i], a_res[j] + b_pre[i] - b_pre[j]);
    	}
    }

    cout << endl;
    for(int i = 0; i <=m ; ++i) cout << a_res[i] << " ";
    cout << endl;
	for(int i = 0; i <=m ; ++i) cout << b_res[i] << " ";
	    cout << endl;
	for(int i = 0; i <=m ; ++i) cout << a_pre[i] << " ";
	    cout << endl;
	for(int i = 0; i <=m ; ++i) cout << b_pre[i] << " ";
	    cout << endl;
		for(int i = 0; i <=m ; ++i) cout << a[i] << " ";
	    cout << endl;
	for(int i = 0; i <=m ; ++i) cout << b[i] << " ";
	    cout << endl;

    cout << min(a_res[m], b_res[m]) << endl;
}


#include <bits/stdc++.h>
using namespace std;

// a == '.', b == '#'

int main() {
    ios::sync_with_stdio(false);
    int n,m,x,y; cin >> n >> m >> x >> y; y = min(y, m);
    int a[m+1], b[m+1], a_pre[m+1], b_pre[m+1], a_res[m+1], b_res[m+1];
    for(int i = 0; i <= m; ++i) a[i] = b[i] = 0;
    char c;
    for(int i = 0; i < n; ++i) {
    	for(int j = 1; j <= m; ++j) {
    		cin >> c;
    		if (c == '.') {
    			++a[j];
    		} else {
    			++b[j];
    		}
    	}
    }

    a_pre[0] = b_pre[0] = 0;
    for(int i = 1; i <= m; ++i) a_pre[i] = a_pre[i-1] + a[i];
    for(int i = 1; i <= m; ++i) b_pre[i] = b_pre[i-1] + b[i];

    for(int i = 0; i < x; ++i) a_res[i] = b_res[i] = -1;
    for(int i = x; i <= y; ++i) {
    	a_res[i] = a_pre[i];
    	b_res[i] = b_pre[i];
    }
    for(int i = y+1; i <= m; ++i) a_res[i] = b_res[i] = m*n;
    for(int i = x+1; i <= m; ++i) {
    	for(int j = i - y; j <= i - x; ++j) {
    		if (j >= x)
    			a_res[i] = min(a_res[i], b_res[j] + a_pre[i] - a_pre[j]);
    	}
    	for(int j = i - y; j <= i - x; ++j) {
    		if (j >= x)
    			b_res[i] = min(b_res[i], a_res[j] + b_pre[i] - b_pre[j]);
    	}
    }

 //    cout << endl;
 //    for(int i = 0; i <=m ; ++i) cout << a_res[i] << " ";
 //    cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << b_res[i] << " ";
	//     cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << a_pre[i] << " ";
	//     cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << b_pre[i] << " ";
	//     cout << endl;
	// 	for(int i = 0; i <=m ; ++i) cout << a[i] << " ";
	//     cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << b[i] << " ";
	//     cout << endl;

    cout << min(a_res[m], b_res[m]) << endl;
}


#include <bits/stdc++.h>
using namespace std;

// a == '.', b == '#'

int main() {
    ios::sync_with_stdio(false);
    int n,m,x,y; cin >> n >> m >> x >> y; y = min(y, m);
    int a[m+1], b[m+1], a_pre[m+1], b_pre[m+1], a_res[m+1], b_res[m+1];
    for(int i = 0; i <= m; ++i) a[i] = b[i] = 0;
    char c;
    for(int i = 0; i < n; ++i) {
    	for(int j = 1; j <= m; ++j) {
    		cin >> c;
    		if (c == '.') {
    			++a[j];
    		} else {
    			++b[j];
    		}
    	}
    }

    a_pre[0] = b_pre[0] = 0;
    for(int i = 1; i <= m; ++i) a_pre[i] = a_pre[i-1] + a[i];
    for(int i = 1; i <= m; ++i) b_pre[i] = b_pre[i-1] + b[i];

    for(int i = 0; i < x; ++i) a_res[i] = b_res[i] = -1;
    for(int i = x; i <= y; ++i) {
    	a_res[i] = a_pre[i];
    	b_res[i] = b_pre[i];
    }
    for(int i = x+1; i <= m; ++i) {
    	a_res[i] = INT_MAX;
    	for(int j = i - y; j <= i - x; ++j) {
    		if (j >= x)
    			a_res[i] = min(a_res[i], b_res[j] + a_pre[i] - a_pre[j]);
    	}
    	b_res[i] = INT_MAX;
    	for(int j = i - y; j <= i - x; ++j) {
    		if (j >= x)
    			b_res[i] = min(b_res[i], a_res[j] + b_pre[i] - b_pre[j]);
    	}
    }

 //    cout << endl;
 //    for(int i = 0; i <=m ; ++i) cout << a_res[i] << " ";
 //    cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << b_res[i] << " ";
	//     cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << a_pre[i] << " ";
	//     cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << b_pre[i] << " ";
	//     cout << endl;
	// 	for(int i = 0; i <=m ; ++i) cout << a[i] << " ";
	//     cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << b[i] << " ";
	//     cout << endl;

    cout << min(a_res[m], b_res[m]) << endl;
}


#include <bits/stdc++.h>
using namespace std;

// a == '.', b == '#'

int main() {
    ios::sync_with_stdio(false);
    int n,m,x,y; cin >> n >> m >> x >> y;
    int a[m+1], b[m+1], a_pre[m+1], b_pre[m+1], a_res[m+1], b_res[m+1];
    for(int i = 0; i <= m; ++i) a[i] = b[i] = 0;
    char c;
    for(int i = 0; i < n; ++i) {
    	for(int j = 1; j <= m; ++j) {
    		cin >> c;
    		if (c == '.') {
    			++a[j];
    		} else {
    			++b[j];
    		}
    	}
    }

    a_pre[0] = b_pre[0] = 0;
    for(int i = 1; i <= m; ++i) a_pre[i] = a_pre[i-1] + a[i];
    for(int i = 1; i <= m; ++i) b_pre[i] = b_pre[i-1] + b[i];

    for(int i = 0; i < x; ++i) a_res[i] = b_res[i] = -1;
    for(int i = x; i <= y; ++i) {
    	a_res[i] = a_pre[i];
    	b_res[i] = b_pre[i];
    }
    for(int i = x+1; i <= m; ++i) {
    	a_res[i] = INT_MAX;
    	for(int j = i - y; j <= i - x; ++j) {
    		if (b_res[j] != -1)
    			a_res[i] = min(a_res[i], b_res[j] + a_pre[i] - a_pre[j]);
    	}
    	b_res[i] = INT_MAX;
    	for(int j = i - y; j <= i - x; ++j) {
    		if (a_res[j] != -1)
    			b_res[i] = min(b_res[i], a_res[j] + b_pre[i] - b_pre[j]);
    	}
    }

 //    cout << endl;
 //    for(int i = 0; i <=m ; ++i) cout << a_res[i] << " ";
 //    cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << b_res[i] << " ";
	//     cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << a_pre[i] << " ";
	//     cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << b_pre[i] << " ";
	//     cout << endl;
	// 	for(int i = 0; i <=m ; ++i) cout << a[i] << " ";
	//     cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << b[i] << " ";
	//     cout << endl;

    cout << min(a_res[m], b_res[m]) << endl;
}