#include <bits/stdc++.h>
using namespace std;
template <class T>
int len(const T& c) {
  return (int)c.size();
}
vector<string> v;
string s;
int n, m, x, y;
vector<int> col[2];
int dp[1005][1005][2];
int fun(int pos, int wid, int color) {
  if (wid > y) return 10611095;
  if (pos == m && wid >= x) return 0;
  if (pos == m) return 10611095;
  int& ret = dp[pos][wid][color];
  if (ret != -1) return ret;
  ret = 10611095;
  int t1 = 10611095, t2 = 10611095;
  if (wid < x)
    t1 = fun(pos + 1, wid + 1, color) + col[1 - color][pos];
  else {
    t1 = fun(pos + 1, wid + 1, color) + col[1 - color][pos];
    t2 = fun(pos + 1, 1, 1 - color) + col[color][pos];
  }
  return ret = min(t1, t2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> x >> y;
  for (int i(0), _n(n); i < _n; ++i) {
    cin >> s;
    v.push_back(s);
  }
  int t1, t2;
  for (int i(0), _n(m); i < _n; ++i) {
    t1 = 0;
    t2 = 0;
    for (int j(0), _n(n); j < _n; ++j) {
      if (v[j][i] == '#')
        t1++;
      else
        t2++;
    }
    col[0].push_back(t1);
    col[1].push_back(t2);
  }
  memset(dp, -1, sizeof(dp));
  cout << min(fun(0, 0, 0), fun(0, 0, 1));
}
