#include <bits/stdc++.h>
using namespace std;
template <class F, class T>
T convert(F a, int p = -1) {
  stringstream ss;
  if (p >= 0) ss << fixed << setprecision(p);
  ss << a;
  T r;
  ss >> r;
  return r;
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T cube(T x) {
  return x * x * x;
}
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return s == 0 ? 0 : cntbit(s >> 1) + (s & 1);
}
const long double PI = acos(-1.0);
const long double eps = 1e-9;
const int dr[] = {-1, 0, +1, 0};
const int dc[] = {0, +1, 0, -1};
const int inf = (int)1e7 + 5;
const long long linf = (long long)1e16 + 5;
const long long mod = (long long)1e9 + 7;
int trang[2000], den[2000];
int F1[2000][2000];
int F2[2000][2000];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  memset(trang, 0, sizeof(trang));
  memset(den, 0, sizeof(den));
  string s;
  for (int i = (1); i <= (n); ++i) {
    cin >> s;
    for (int j = 0; j < (((int)(s).size())); ++j) {
      if (s[j] == '.') trang[j + 1]++;
      if (s[j] == '#') den[j + 1]++;
    }
  }
  for (int i = (1); i <= (y); ++i) {
    F1[1][i] = inf;
    F2[1][i] = inf;
  }
  F1[1][1] = den[1];
  F2[1][1] = trang[1];
  for (int i = (2); i <= (m); ++i) {
    F1[i][1] = inf;
    for (int j = (x); j <= (y); ++j)
      F1[i][1] = min(F2[i - 1][j] + den[i], F1[i][1]);
    F2[i][1] = inf;
    for (int j = (x); j <= (y); ++j)
      F2[i][1] = min(F1[i - 1][j] + trang[i], F2[i][1]);
    for (int j = (2); j <= (y); ++j) {
      F1[i][j] = F1[i - 1][j - 1] + den[i];
      F2[i][j] = F2[i - 1][j - 1] + trang[i];
    }
  }
  int res = inf;
  for (int i = (x); i <= (y); ++i) {
    res = min(res, F1[m][i]);
    res = min(res, F2[m][i]);
  }
  cout << res << '\n';
}
