cho.sh
Notes
Loading...

Artist Lee Dongho

Time limit

2s

Memory limit

128 MB

Problem

Artist Lee Dongho paints on a canvas with N rows and M columns. The canvas is divided into 1 x 1 cells, and each cell already has a target color: black (B) or white (W).

Dongho uses a special brush. One use of the brush paints one contiguous horizontal segment in a single row. The segment starts and ends on cell borders, and before each use Dongho may choose either black or white. The color cannot change during that brush use.

To preserve the painting, each cell may be painted at most once. Because the brush can be used at most K times, Dongho may be unable to paint the target picture exactly. A cell is considered incorrect if it is painted with the wrong color or if it is not painted at all.

Given the canvas size, the brush limit, and the target picture, find the minimum possible number of incorrect cells.

Input

The first line contains three integers N, M, and K: the number of rows, the number of columns, and the maximum number of brush uses.

N and M are positive integers at most 50, and K is a nonnegative integer at most 3000.

Each of the next N lines contains a string of length M describing one row of the target picture. Every character is either B or W.

Output

Print one integer: the minimum possible number of incorrect cells.