#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 0x3f3f3f3f, MOD = 1000000007;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MN = 1e3 + 5;
int n, m, x, y;
int dp[2][MN][MN], c[2][MN];
bool grid[MN][MN];
int main() {
  scanf("%d%d%d%d", &n, &m, &x, &y);
  for (int i = (1); i <= (n); ++i) {
    for (int j = (1); j <= (m); ++j) {
      char c;
      scanf(" %c", &c);
      grid[i][j] = c == '#';
    }
  }
  for (int j = (1); j <= (m); ++j) {
    for (int i = (1); i <= (n); ++i) {
      c[0][j] += grid[i][j];
    }
    c[1][j] = n - c[0][j];
  }
  memset(dp, 0x3f, sizeof dp);
  dp[0][1][1] = c[0][1];
  dp[1][1][1] = c[1][1];
  for (int col = (1); col <= (m); ++col) {
    for (int clr = (0); clr <= (1); ++clr) {
      for (int w = (x); w <= (y); ++w) {
        dp[clr][col][1] =
            min(dp[clr][col][1], dp[clr ^ 1][col - 1][w] + c[clr][col]);
      }
      for (int w = (2); w <= (y); ++w) {
        dp[clr][col][w] = dp[clr][col - 1][w - 1] + c[clr][col];
      }
    }
  }
  (c, 2, m + 1);
  (dp[0], m + 1, y + 1);
  (dp[1], m + 1, y + 1);
  int ans = INF;
  for (int i = (x); i <= (y); ++i) {
    ans = min(ans, dp[0][m][i]);
    ans = min(ans, dp[1][m][i]);
  }
  printf("%d\n", ans);
}
