Under construction

Still being built. Things may change

The Destruction of the Crystals

Time limit2sMemory limit512 MB

Summary
Given a board with crystals and bombs, find the most crystals a chain of bomb explosions can destroy when each bomb blasts its row or column.
Level

Medium6 of 10

Topics
Graph, BFS, Matrix
Solved
No attempts yet

Statement

Once upon a time, Zenyk came up with a new magical game for his friends. He brought an n×mn \times m board and placed kk crystals on it. After that, he also placed bb bombs on the board.

Upon explosion, each bomb destroys all the crystals either in its row or in its column. It also detonates all the bombs in the chosen direction. The direction of the explosion (row or column) for each bomb is chosen by the friends. Different bombs may have different directions.

The objective of the game is to choose the first bomb and the directions to detonate in such a way that the number of destroyed crystals is the largest possible.

Input

The first line contains four integers nn, mm, kk, bb (1≤n,m≤30001 \le n, m \le 3000, 0≤k+b≤n×m0 \le k + b \le n \times m). They are the dimensions of the board, the number of crystals on it, and the number of bombs.

The next nn lines describe the board with mm characters per line:

  • "." is an empty cell,
  • "k" is a crystal,
  • "b" is a bomb.

Output

Print a single integer: the maximum possible number of destroyed crystals.

Examples2

  1. Example 1

    Input
    7 3 4 5
    bbb
    ..b
    ..b
    k..
    k..
    k..
    k..
    
    Expected output
    4
    
  2. Example 2

    Input
    3 3 4 2
    k..
    kk.
    bbk
    
    Expected output
    3