#include <bits/stdc++.h>
template <class T>
inline T bigmod(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <typename T>
T nCr(T n, T r) {
  if (r > n - r) r = n - r;
  int ans = 1, i;
  for (i = 1; i <= r; i++) {
    ans *= n - r + i;
    ans /= i;
  }
  return ans;
}
using namespace std;
int m, y, n, x;
int ch1[1005], ch2[1005];
int visit[1005][2][1005];
int go(int pos, bool has, int sz) {
  if (pos == m) {
    if (sz < x) return 1000000000;
    return 0;
  }
  if (visit[pos][has][sz] != -1) return visit[pos][has][sz];
  int ans = 1000000000;
  if (has == true) {
    if (sz < y)
      ans = ((ans) < (go(pos + 1, true, sz + 1) + ch1[pos])
                 ? (ans)
                 : (go(pos + 1, true, sz + 1) + ch1[pos]));
    if (sz >= x)
      ans = ((ans) < (go(pos + 1, false, 1) + ch2[pos])
                 ? (ans)
                 : (go(pos + 1, false, 1) + ch2[pos]));
  } else {
    if (sz < y)
      ans = ((ans) < (go(pos + 1, false, sz + 1) + ch2[pos])
                 ? (ans)
                 : (go(pos + 1, false, sz + 1) + ch2[pos]));
    if (sz >= x)
      ans = ((ans) < (go(pos + 1, true, 1) + ch1[pos])
                 ? (ans)
                 : (go(pos + 1, true, 1) + ch1[pos]));
  }
  return visit[pos][has][sz] = ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(0);
  int testCase = 1;
  for (int t = 1; t <= testCase; t++) {
    cin >> n >> m >> x >> y;
    memset(visit, (-1), sizeof(visit));
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      for (int j = 0; j < m; j++) {
        if (s[j] == '#')
          ch1[j]++;
        else
          ch2[j]++;
      }
    }
    int ans = go(0, true, 0);
    cout << ((ans) < (go(0, false, 0)) ? (ans) : (go(0, false, 0))) << endl;
  }
}
