#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T gcd(T a, T b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
template <typename T>
inline T lcm(T a, T b) {
  return (a * b) / gcd(a, b);
}
int n, t, m, a, b[1111][3][1111], c[3][1111], x, y, ans;
char bar[1111][1111];
void solve() {
  for (int i = 0, _n = (m); i < _n; i++) {
    int sum = 0;
    for (int j = 0, _n = (n); j < _n; j++) {
      if (bar[j][i] == '#') sum++;
    }
    c[1][i + 1] = sum;
    c[2][i + 1] = n - sum;
  }
  memset(b, 1000111222, sizeof b);
  b[1][1][1] = c[1][1];
  b[1][2][1] = c[2][1];
  for (int i = (2), _b = (m); i <= _b; i++) {
    for (int j = (1), _b = (2); j <= _b; j++) {
      for (int k = (2), _b = (y); k <= _b; k++) {
        if (b[i - 1][j][k - 1] == 1000111222)
          b[i][j][k] = 1000111222;
        else
          b[i][j][k] = b[i - 1][j][k - 1] + c[j][i];
      }
      int p = (j == 1 ? 2 : 1);
      int tmp = 1000111222;
      for (int k = (x), _b = (y); k <= _b; k++) {
        tmp = min(tmp, b[i - 1][p][k]);
      }
      b[i][j][1] = tmp + c[j][i];
    }
  }
  ans = 1000111222;
  for (int j = (1), _b = (2); j <= _b; j++)
    for (int k = (x), _b = (y); k <= _b; k++) {
      ans = min(ans, b[m][j][k]);
    }
  cout << ans << endl;
}
int main() {
  scanf(" %d %d %d %d ", &n, &m, &x, &y);
  for (int i = 0, _n = (n); i < _n; i++) {
    gets(bar[i]);
  }
  solve();
  return 0;
}
