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 "#".
from math import inf


n,m,x,y = map(int,input().split())
cols = []
grid = []
for i in range(n):
  grid.append(list(input()))


for j in range(m):
  black_cost = 0
  white_cost = 0
  for i in range(n):
    if grid[i][j]=='.':
      black_cost +=1
    if grid[i][j] == '#':
      white_cost +=1
  cols.append((white_cost,black_cost))

# print(cols)
def valid(j):
  return  -1<j<m
c = 0

mem = [[[-1]*5 for _ in range(m+9)  ] for _ in range(m+9)]
# print(mem[0][0])

def paint(j=0,prev=2,width = 0):
  global c
  c+=1
  if not valid(j):
    if x<= width <=y:
      # print(x,'<',width,'<',y)
      return 0
    # print('imp')
    return inf
  # try:
  if mem[j][width][prev] !=-1:
    return mem[j][width][prev] 
  # except :
    # print(j,width,prev,'caused error')
    # exit()

  if prev == 0:
    if width <x:
      mem[j][width][prev] = cols[j][0] + paint(j+1,0,width+1)
      return mem[j][width][prev] 
    if width == y :
      mem[j][width][prev] = cols[j][1] + paint(j+1,1,1)
      return mem[j][width][prev] 
  if prev == 1: 
    if width <x:
      mem[j][width][prev] = cols[j][1]+ paint(j+1,1,width+1)
      return mem[j][width][prev] 
    if width == y :
      mem[j][width][prev] = cols[j][0] + paint(j+1,0,1)
      return mem[j][width][prev] 

  # print('trying all colors at',j)
  p1 = cols[j][0]+ paint(j+1,0, width+1 if prev == 0 else 1)
  # if p1 == inf :
    # print('invalidated white at ',j)
  p2 = cols[j][1] + paint(j+1,1,width+1 if prev==1 else 1)
  # if p2 == inf :
    # print('invalidated black at ',j)
  # if p1 != inf and p2 != inf :
  #   print('both colered worked',j,'and width',width)
  mem[j][width][prev]  = min(p1,p2)
  return mem[j][width][prev] 





print(paint())
# print(c)

