#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int dx2[] = {1, -1, -1, 1, 0, 0, -1, 1};
int dy2[] = {1, -1, 1, -1, 1, -1, 0, 0};
int kmx[] = {-1, -1, 1, 1, 2, -2, 2, -2};
int kmy[] = {2, -2, 2, -2, -1, -1, 1, 1};
class Timer {
 public:
  clock_t T;
  Timer() { T = clock(); }
  ~Timer() {
    fprintf(stderr, "\n%.3f\n", double(clock() - T) / CLOCKS_PER_SEC);
  }
};
int read() {
  int x;
  scanf("%d", &x);
  return x;
}
long long readL() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const int N = 1e3 + 5;
int n, m, x, y;
char s[N];
int c[N][2];
int dp[N][N][3];
int play(int i, int len, int pr) {
  if (len > y) return 1000000000;
  if (i == m) {
    return (len < x) * 1000000000;
  }
  int &res = dp[i][len][pr + 1];
  if (res != -1) return res;
  res = 1000000000;
  if (pr != -1) {
    if (len >= x) {
      res = min(res, min(play(i + 1, len + 1, pr) + c[i][!pr],
                         play(i + 1, 1, !pr) + c[i][pr]));
    } else {
      res = min(res, play(i + 1, len + 1, pr) + c[i][!pr]);
    }
  } else {
    res =
        min(res, min(play(i + 1, 1, 0) + c[i][1], play(i + 1, 1, 1) + c[i][0]));
  }
  return res;
}
int main() {
  n = read();
  m = read();
  x = read();
  y = read();
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    for (int j = 0; j < m; j++) {
      c[j][s[j] == '#']++;
    }
  }
  memset(dp, -1, sizeof dp);
  printf("%d\n", play(0, 0, -1));
  return 0;
}
