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(col, width, last, n, m, x, y, count_dots, memo):
    if col == m:
        if x <= width  and width <= y:
            return 0
        else:
            return float('inf')

    ans = memo[col][width][last]

    if ans != -1:
        return ans

    dots = 1000000
    still_can_put_dots = last == 0 and width < y
    can_change_to_dots = last == 1 and x <= width
    if col == 0 or still_can_put_dots or can_change_to_dots:
        new_width = 1 if last != 0 else width + 1
        dots = n - count_dots[col]
        dots += solve(col + 1, new_width, 0, n, m, x, y, count_dots, memo)
        
    hashes = 1000000
    still_can_put_hashes = last == 1 and width < y
    can_change_to_hashes = last == 0 and x <= width
    if col == 0 or still_can_put_hashes or can_change_to_hashes:
        new_width = 1 if last != 1 else width + 1
        hashes = count_dots[col]
        hashes += solve(col + 1, new_width, 1, n, m, x, y, count_dots, memo)

    ans = min(dots, hashes)
    memo[col][width][last] = ans

    return ans
    

def main():
    n, m, x, y = map(int, input().split())
    count_dots = [0]*m
    for _ in range(n):
        line = input()
        for i, ch in enumerate(line):
            if ch == '.':
                count_dots[i] += 1
    memo = [[[-1 for _ in range(3)] for _ in range(y+1)] for _ in range(m)]
    col = 0
    width = 0
    mode = 2 # Nothing
    sol = solve(col, width, mode, n, m, x, y, count_dots, memo)
    print(sol)

if __name__ == '__main__':
    main()
