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.setrecursionlimit(10**7)
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
############ ---- Input Functions ---- ############

def Barcode():
    def count_changes(sum_count_dots,col_index,num_columns,to_change_to_dots,n):
        if not to_change_to_dots:
            if col_index == 0:
                reversal = sum_count_dots[col_index+num_columns-1]
            else:
                reversal = sum_count_dots[col_index+num_columns-1] - sum_count_dots[col_index-1]
        
        else:
            if col_index == 0:
                reversal = (num_columns*n) - sum_count_dots[col_index+num_columns-1]
            else:
                reversal = (num_columns*n) - (sum_count_dots[col_index+num_columns-1] - sum_count_dots[col_index-1])
        
        return reversal


    
    def bar_recur(consective_dots,consecutive_hash,sum_count_dots,col_index,n,m):
        if col_index == m:
            return 0 
        
        elif col_index > m:
            return (n*m)

        else:
            if consective_dots == 0 and consecutive_hash == 0:
                changes1 = count_changes(sum_count_dots,col_index,x,True,n) + bar_recur(x,0,sum_count_dots,col_index+x,n,m)
                changes2 = count_changes(sum_count_dots,col_index,x,False,n) + bar_recur(0,x,sum_count_dots,col_index+x,n,m)
                return min(changes1,changes2)
            
            elif consective_dots < y and consecutive_hash == 0:
                changes1 = count_changes(sum_count_dots,col_index,1,True,n) + bar_recur(consective_dots+1,0,sum_count_dots,col_index+1,n,m)
                changes2 = count_changes(sum_count_dots,col_index,x,False,n) + bar_recur(0,x,sum_count_dots,col_index+x,n,m)
                return min(changes1,changes2)
            
            elif consective_dots == 0 and consecutive_hash < y:
                changes1 = count_changes(sum_count_dots,col_index,x,True,n) + bar_recur(x,0,sum_count_dots,col_index+x,n,m)
                changes2 = count_changes(sum_count_dots,col_index,1,False,n) + bar_recur(0,consecutive_hash+1,sum_count_dots,col_index+1,n,m)
                return min(changes1,changes2)
            
            elif consective_dots == y:
                changes = count_changes(sum_count_dots,col_index,x,False,n) + bar_recur(0,x,sum_count_dots,col_index+x,n,m)
                return changes
            
            elif consecutive_hash == y:
                changes = count_changes(sum_count_dots,col_index,x,True,n) + bar_recur(x,0,sum_count_dots,col_index+x,n,m)
                return changes                

    n,m,x,y = invr()

    num_dots = [0]*m
    for i in range(n):
        row = insr()
        for col_index,element in enumerate(row):
            if element == '.':
                num_dots[col_index] += 1
    
    sum_count_dots = []
    running_sum = 0
    for count in num_dots:
        running_sum += count 
        sum_count_dots.append(running_sum)

    
    final_answer = bar_recur(0,0,sum_count_dots,0,n,m)
    print(final_answer)
    return

Barcode()