import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
while ((str = reader.readLine()) != null) {
String[] ints
= str.
split(" "); int sy
= Integer.
parseInt(ints
[0])-1; int sx
= Integer.
parseInt(ints
[1])-1; int ty
= Integer.
parseInt(ints
[2])-1; int tx
= Integer.
parseInt(ints
[3])-1;
char[][] cbuf = new char[sy+1+ty+1][sx+1+ty+1];
/*for (int y = 0; y < ty+1; y++) {
for (int x = 0; x < sx+1+ty+1; x++) {
cbuf[y][x]='.';
}
}*/
for (int y = 0; y < sy+1; y++) {
str = reader.readLine();
char[] n=str.toCharArray();
for (int x = 0; x < sx+1; x++) {
cbuf[y+2][x+2]=n[x];
}
}
sy+=ty+1;
sx+=tx+1;
for (int y = 0; y <= sy; y++) {
}
for(int oy=0; oy<=ty; oy++) {
for(int ox=0; ox<=tx; ox++) {
/*System.err.println("oy:"+oy);
System.err.println("ty:"+ty);
System.err.println("ox:"+ox);
System.err.println("tx:"+tx);*/
int countForThisOffset=0;
for(int y=oy; y<=sy; y+=ty+1) {
for(int x=ox; x<=sx; x+=tx+1) {
boolean isEmpty=true;
for(int iy=y; iy<=y+ty; iy++) {
for(int ix=x; ix<=x+tx; ix++) {
//System.err.print("iy:"+iy+" ix:"+ix);
if(ix<=sx && iy<=sy) {
if(cbuf[iy][ix]=='X') isEmpty=false;
//System.err.print(cbuf[iy][ix]);
}
}
//System.err.println();
}
if(isEmpty==false) countForThisOffset++;
//System.err.println(countForThisOffset);
}
}
//System.err.println("n");
//System.err.println(countForThisOffset);
if(minCount>countForThisOffset) minCount=countForThisOffset;
}
}
}
}
}