// goodwincommaderek@gmail.com import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class vrplayspace_dg_betterac { static int solve(int R, int C, int S, int T, char[][] map) { if (S > T) { S ^= T; T ^= S; S ^= T; } int[][] firstBlockLeft = new int[R][C+1]; for(int r = 0; r < R; r++) { firstBlockLeft[r][0] = -1; for(int c = 0; c < C; c++) { firstBlockLeft[r][c+1] = (map[r][c] == '.')? firstBlockLeft[r][c]: c; } } int[][] firstBlockUp = new int[R+1][C]; Arrays.fill(firstBlockUp[0], -1); for(int r = 0; r < R; r++) { for(int c = 0; c < C; c++) { firstBlockUp[r+1][c] = (map[r][c] == '.')? firstBlockUp[r][c]: r; } } // stack contains potential topleft corners int[] stackR = new int[R+1]; int[] stackC = new int[R+1]; int sp = 0; // loop through bottom right corners int count = 0; for(int r = 0; r < R; r++) { for(int c = 0; c < C; c++) { if (map[r][c] == '0') { sp = 0; continue; } // put something on the stack here (if applicable) if (sp == 0 || firstBlockUp[r+1][c] + 1 < stackR[sp-1]) { stackR[sp] = firstBlockUp[r+1][c] + 1; stackC[sp] = c; sp++; } // take stuff off the stack if we have to do so for the next thing. process rectangles while doing so int popUntil = (c < C-1)? firstBlockUp[r+1][c+1] + 1: 9999999; boolean poppedSomething = false; for (; sp != 0 && popUntil > stackR[sp-1];){ poppedSomething = true; sp--; // rectangle's topleft corner is (stackR[sp], stackC[sp]) // is there anything below the rectangle? if (r == R-1 || stackC[sp] <= firstBlockLeft[r+1][c+1]) { // process this rectangle int side1 = r - stackR[sp] + 1; int side2 = c - stackC[sp] + 1; if (side1 > side2) { side1 ^= side2; side2 ^= side1; side1 ^= side2; } if (S <= side1 && T <= side2) { // System.out.println(stackR[sp]+" "+stackC[sp]+" "+r+" "+c); count++; } } } if (poppedSomething) { // put the thing you last took off back on (but at a new R coordinate) if possible if (sp == 0 || popUntil < stackR[sp-1]) { stackR[sp] = popUntil; // stackC is already set sp++; } } } } return count; } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] in; int $; in = br.readLine().split(" "); $ = 0; int R = Integer.parseInt(in[$++]); int C = Integer.parseInt(in[$++]); int S = Integer.parseInt(in[$++]); int T = Integer.parseInt(in[$++]); char[][] map = new char[R][]; for (int r = 0; r < R; r++) { map[r] = br.readLine().toCharArray(); } int ans = solve(R,C,S,T,map); System.out.println(ans); } }