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 sys

sys.stdin = open(
    './in.txt',"r"
)
sys.stdout = open("./out.txt","w")









from collections import Counter

def isnext(el,row):
     indexes = []
     for i in range(len(row)):
         if el == row[i]:
             indexes.append(i)
     for i in range(len(indexes)-1):
        if abs(indexes[i] - indexes[i + 1]) == 1:
            return True
     return False
    
def checkRow(c_el,row,co):
    c = Counter(row)
    for el in c:
        if c[el] > max :
            if isnext(el,row):
                if c_el == "." and el == ".":
                    co = co + 1
                    c_el = "#"
                elif c_el == "#" and el == "#"   :
                    co = co + 1
                    c_el = "."
        if c[el] < min:
            co = co + 1
            c_el = c[el]

    return c_el,co
   


def checkCol(c_el,col,co):
    c = Counter(col)
    ch = c.most_common()
    if len(ch) == 1:
        if ch[0] == ".":
            co = co + 1
            c_el = "."
        elif ch[0]=="#":
            co = co + 1
            c_el ="#"
   

    return c_el,co

rows,cols,min,max =  map(int,input().split())

d = [list(map(str,input())) for i in range(rows) ]
# db_row = [-1 for row in range(rows)]
# db_col = [-1 for col in range(cols)]
def solve(d):
    c = 0
    for row in range(rows):
        for col in range(cols):
              elm = d[row][col]
              ex_el,c = checkRow(elm,d[row],c)
              d[row][col] = ex_el
              sp_col = [rw[col] for rw in d]
              el,c = checkCol(ex_el,sp_col,c)

              d[row][col] = el


    print(c-1)    
solve(d)    
print(d) 
