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, min_bar_width, max_bar_width):
    """
    returns the minimum number of pixels that have to be changed
    to make img (n x m) a valid barcode
    """
    dp = [[[0, 0], [0, 0]] for _ in range(m+1)]

    for i in range(0, m):
        num_white = sum(img[j][i] == '.' for j in range(n))
        num_black = n - num_white

        if dp[i][1][1] + 1 <= max_bar_width:
            if dp[i][1][0] <= dp[i][0][0]:
                dp[i+1][1][1] = dp[i][1][1] + 1
                dp[i+1][1][0] = dp[i][1][0] + num_white
            else:
                dp[i+1][1][1] = 1
                dp[i+1][1][0] = dp[i][0][0] + num_white
        else:
            dp[i+1][1][0] = float('infinity')

        if dp[i][1][1] == 0 or dp[i][1][1] >= min_bar_width:
            if dp[i][1][0] <= dp[i][0][0]:
                dp[i+1][0][0] = dp[i][1][0] + num_black
            else:
                dp[i+1][0][0] = dp[i][0][0] + num_black
        else:
            dp[i+1][0][0] = float('infinity')

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


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

    ans = make_barcode(img, n, m, min_bar_width, max_bar_width)
    print(ans)


if __name__ == "__main__":
    main()
