#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3 + 5;
const int INF = 1e9 + 7;
int n, m, x, y, dp[MAX][MAX][2], cnt[MAX][2];
char a[MAX][MAX];
int solve(int i, int j, int color) {
if (j > y || j < x) return INF;
if (i == m + 1) return (j >= x && j <= y) ? 0 : INF;
if (dp[i][j][color] != -1) return dp[i][j][color];
int res = INF;
if (j + 1 <= y) res = min(res, solve(i + 1, j + 1, color) + cnt[i][color ^ 1]);
if (j >= x) res = min(res, solve(i + 1, 1, color ^ 1) + cnt[i][color]);
return dp[i][j][color] = res;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> m >> x >> y;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
cnt[j][0] += (a[i][j] == '#');
cnt[j][1] += (a[i][j] == '.');
}
memset(dp, -1, sizeof dp);
cout << min(solve(1, 0, 0) + cnt[1][1], solve(1, 0, 1) + cnt[1][0]);
return 0;
}