#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int maxn = 1005;
int black = 1, white = 0, n, m, x, y;
char arr[maxn][maxn];
int count_black[maxn];
inline int count_white(int idx) { return n * idx - count_black[idx]; }
int dp[maxn][2];
int solve(int columns, int color) {
  int ans = 1 << 30;
  if (columns == 0) return dp[0][color] = 0;
  if (dp[columns][color] != -1) return dp[columns][color];
  if (columns < x) return dp[columns][color] = 1 << 30;
  for (int i = x; i <= y; ++i) {
    if (color) {
      ans = min(ans, solve(columns - i, 0) + count_black[columns] -
                         count_black[columns - i]);
    } else {
      ans = min(ans, solve(columns - i, 1) + count_white(columns) -
                         count_white(columns - i));
    }
    if (columns - i < 0) break;
  }
  return dp[columns][color] = ans;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> x >> y;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      cin >> arr[i][j];
      if (arr[i][j] == '#') count_black[j]++;
    }
  memset(dp, -1, sizeof dp);
  for (int i = 1; i <= m; ++i) count_black[i] += count_black[i - 1];
  cout << min(solve(m, black), solve(m, white)) << '\n';
  return 0;
}
