#include <bits/stdc++.h>
const int N = 1e3 + 10;
const int MOD = 1e9 + 9;
const int oo = 1e8;
using namespace std;
string a[N];
int n, m, x, y, w[N], b[N], f1[N], f2[N];
int t1[N][N], t2[N][N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> x >> y;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int j = 0; j < m; j++) {
    int cx = 0, cy = 0;
    for (int i = 0; i < n; i++)
      if (a[i][j] == '#')
        cx++;
      else
        cy++;
    w[j] = cx;
    b[j] = cy;
  }
  for (int j = 0; j < m; j++) {
    int sum1 = 0;
    int sum2 = 0;
    for (int i = j; i < min(j + y, m); i++) {
      sum1 += w[i];
      sum2 += b[i];
      if (i - j + 1 < x) continue;
      t1[j + 1][i - j + 1] = sum1;
      t2[j + 1][i - j + 1] = sum2;
    }
  }
  for (int i = 0; i <= m; i++) f1[i] = oo, f2[i] = oo;
  for (int j = x; j <= min(y, m); j++) {
    f1[j] = t1[1][j];
    f2[j] = t2[1][j];
  }
  int d = x, c = min(y, m);
  while (d <= m) {
    for (int i = d; i <= c; i++) {
      for (int j = x; j <= y; j++) {
        int k = i + j;
        if (k > m) break;
        f1[k] = min(f1[k], t1[i + 1][j] + f2[i]);
        f2[k] = min(f2[k], t2[i + 1][j] + f1[i]);
      }
    }
    d = d + x;
    c = min(c + y, m);
  }
  cout << min(f1[m], f2[m]);
  return 0;
}
