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 "#".
def solve(i,esNegro):
    global arrN,arrB,sumN,sumB,n,m,x,y,dp
    if i==m-1:
        if esNegro==True:
            return arrB[i]
        else:
            return arrN[i]
    elif i>=m:
        return 0
    if esNegro:
        b = 1
    else:
        b = 0
    if dp[i][b] > -1:
        return dp[i][b]
    optimo = 1000000
    for j in range(i+x-1,min(m,i+y),1):
        if esNegro:
            costo = sumB[j]
            if i>0:
                costo -= sumB[i-1]
            optimo  = min(optimo, costo+solve(j+1, not esNegro))
        else:
            costo = sumN[j]
            if i>0:
                costo -= sumN[i-1]
            optimo =  min(optimo, costo+solve(j+1, not esNegro))
    dp[i][b] = optimo
    return optimo

data = list(map(lambda x : int(x), input().split()))
n = data[0]
m = data[1]
x = data[2]
y = data[3]
dp = [[-1]*2]*n
arrN = [0]*m
arrB = [0]*m
sumN = [0]*m
sumB = [0]*m
for i in range(n):
    f = input()
    for j,v in enumerate(f):
        if v=="#":
            arrN[j] += 1
        else:
            arrB[j] += 1
for i in range(m):
    if i==0:
        sumN[i] = arrN[i]
        sumB[i] = arrB[i]
    else:
        sumN[i] = sumN[i-1]+arrN[i]
        sumB[i] = sumB[i-1]+arrB[i]

#print (arrN)
#print (arrB)
#print (sumN)
#print (sumB)
resultado = min(solve(0, False), solve(0, True))
print (str(resultado))
