#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
bool isPowerOfTwo(long long int x) { return x && (!(x & (x - 1))); }
long long int Modular_Exponentiation(long long int x, long long int n,
                                     long long int M) {
  if (n == 0) return 1;
  if (n % 2)
    return (x * Modular_Exponentiation((x * x) % M, n / 2, M)) % M;
  else
    return (Modular_Exponentiation((x * x) % M, n / 2, M)) % M;
}
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 5; i * i <= n; i += 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long int dp[2005][2005][5], arr[2][2005];
char mat[2005][2005];
long long int n, m, x, y;
long long int cost(long long int indx, long long int amount,
                   long long int last) {
  if (indx >= m) {
    if (x <= amount and amount <= y) return 0;
    return 1e9;
  }
  long long int &ans = dp[indx][amount][last];
  if (ans != -1) return ans;
  if (amount == y)
    return ans = (n - arr[last][indx]) + cost(indx + 1, 1, 1 - last);
  else if (amount < x)
    return ans = (n - arr[1 - last][indx]) + cost(indx + 1, amount + 1, last);
  else {
    long long int a1 = n - arr[1 - last][indx], a2 = n - arr[last][indx];
    return ans = min(a1 + cost(indx + 1, amount + 1, last),
                     a2 + cost(indx + 1, 1, 1 - last));
  }
}
void solve() {
  cin >> n >> m >> x >> y;
  for (long long int i = 0; i < n; ++i) {
    string str;
    cin >> str;
    for (long long int j = 0; j < m; ++j) mat[i][j] = str[j];
  }
  memset(dp, -1, sizeof(dp));
  for (long long int j = 0; j < m; ++j) {
    long long int a = 0, b = 0;
    for (long long int i = 0; i < n; ++i) {
      if (mat[i][j] == '#')
        a++;
      else
        b++;
    }
    arr[0][j] = a;
    arr[1][j] = b;
  }
  cout << min(cost(0, 0, 0), cost(0, 0, 1));
}
int32_t main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  for (long long int i = 0; i < T; ++i) {
    solve();
  }
  cerr << "Time taken : " << fixed << setprecision(5)
       << ((float)clock() / CLOCKS_PER_SEC) * 1000 << " ms"
       << "\n";
  cerr << "My CLOCKS_PER_SEC= " << CLOCKS_PER_SEC << "\n";
  return 0;
}
