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 make_barcode(img, n, m, x, y):
    """
    returns the minimum number of pixels that have to be changed
    to make img (n x m) a valid barcode
    """
    maxn = 1004
    col = [0] * maxn
    sumw = [0] * maxn
    sumb = [0] * maxn
    dp = [[0, 0] for _ in range(maxn)]

    for i in range(n):
        for j in range(m):
            if img[i][j] == '.':
                col[j] += 1

    for i in range(m):
        sumw[i+1] = sumw[i] + col[i]
        sumb[i+1] = (i+1)*n - sumw[i+1]

    dp[0][0] = dp[0][1] = 0
    for i in range(1, m+1):
        dp[i][0] = dp[i][1] = float('infinity')
    for i in range(1, m+1):
        for j in range(x, y+1):
            if (i - j < 0):
                continue

        dp[i][0] = min(dp[i][0], dp[i-j][1] + sumb[i] - sumb[i-j])
        dp[i][1] = min(dp[i][1], dp[i-j][0] + sumw[i] - sumw[i-j])

    return min(dp[m][0], dp[m][1])


def main():
    n, m, x, y = map(int, input().split())
    img = [input() for _ in range(n)]

    ans = make_barcode(img, n, m, x, y)
    print(ans)


if __name__ == "__main__":
    main()
