You've got an *n* × *m* pixel picture. Each pixel can be white or black. Your task is to change the colors of as few pixels as possible to obtain a barcode picture.

A picture is a barcode if the following conditions are fulfilled: 
 -  All pixels in each column are of the same color. -  The width of each monochrome vertical line is at least *x* and at most *y* pixels. In other words, if we group all neighbouring columns of the pixels with equal color, the size of each group can not be less than *x* or greater than *y*.
The first line contains four space-separated integers *n*, *m*, *x* and *y* (1 ≤ *n*, *m*, *x*, *y* ≤ 1000; *x* ≤ *y*).

Then follow *n* lines, describing the original image. Each of these lines contains exactly *m* characters. Character "." represents a white pixel and "#" represents a black pixel. The picture description doesn't have any other characters besides "." and "#".
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Integer.min;
import static java.lang.Long.max;


public class Main {
        static FastScanner in=new FastScanner();
        static PrintWriter out=new PrintWriter(System.out);
        public static void main(String[]args) {
                int n=in.nextInt();
                int m=in.nextInt();
                int x=in.nextInt();
                int y=in.nextInt();
                String[]grid=new String[n];
                for (int i=0;i<n;i++)grid[i]=in.next();
                int[] col=new int[m+1];
                int[] col1=new int[m+1];

                for (int c=0;c<m;c++){
                        for (int r=0;r<n;r++){
                                if(grid[r].charAt(c)=='.')col[c+1]++;
                                else col1[c+1]++;
                        }
                }

//                printArray(col);

                int[][] dp=new int[m][2];
                for (int i=0;i<m;i++)dp[i][0]=dp[i][1]=n*m;

                dp[0][0]=col[1];
                dp[0][1]=col1[1];
                for (int i=1;i<x;i++){
                        dp[i][0]+=dp[i-1][0]+col[i];
                        dp[i][1]+=dp[i-1][1]+col1[i];
                }


                for (int i=1;i<m;i++)col[i+1]+=col[i];
                for (int i=1;i<m;i++)col1[i+1]+=col1[i];


                for (int i=x;i<m;i++){
                        for (int j=i-1;j>=-1;j--){
                                if(i-j>=x&&i-j<=y&&(j+1>=x||j+1==0)){
                                        int p=col[i+1]-col[j+1];
                                        int q=col1[i+1]-col1[j+1];
                                        dp[i][0]=min((j<0?0:dp[j][1])+p, dp[i][0]);
                                        dp[i][1]=min((j<0?0:dp[j][0])+q, dp[i][1]);
                                }
                        }
                }
//
//                for (int i=0;i<m;i++)out.print(dp[i][0]+" ");
//                out.println();
//                for (int i=0;i<m;i++)out.print(dp[i][1]+" ");
//                out.println();
                out.println(min(dp[m-1][0],dp[m-1][1]));
                out.close();
        }



        static void printArray(long[]a){
                for (int i=0;i<a.length;i++)out.print(a[i]+" ");
                out.println();
        }
        static void printArray(int[]a){
                for (int i=0;i<a.length;i++)out.print(a[i]+" ");
                out.println();
        }
        static void printArray(String[]a){
                for (int i=0;i<a.length;i++)out.print(a[i]+" ");
                out.println();
        }
        static void printArray(double[]a){
                for (int i=0;i<a.length;i++)out.print(a[i]+" ");
                out.println();
        }
        static void printArray(boolean[]a){
                for (int i=0;i<a.length;i++)out.print(a[i]+" ");
                out.println();
        }
        static class Pair implements Comparable<Pair>{
                int first,second;
                public Pair(int a , int b) {
                        first=a;
                        second=b;
                }
                @Override
                public int compareTo(Pair o) {
                        return first-o.first;
                }
        }
        static class FastScanner{
                BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st=new StringTokenizer("");
                String next() {
                        while (!st.hasMoreTokens())
                                try {
                                        st=new StringTokenizer(br.readLine());
                                } catch (IOException e) {
                                        e.printStackTrace();
                                }
                        return st.nextToken();
                }
                int nextInt() {
                        return Integer.parseInt(next());
                }
                int[] nextArray(int n) {
                        int[] a=new int[n];
                        for (int i=0; i<n; i++) a[i]=nextInt();
                        return a;
                }
                long nextLong() {
                        return Long.parseLong(next());
                }
                double nextDouble() {
                        return Double.parseDouble(next());
                }
        }
}