You are given a table with rows and columns. Each cell contains or .
You must delete exactly one row and exactly one column. The remaining rows and columns then shift to close the gaps. Their original order is preserved.
After that, in one operation, you can change the value of a single cell from to or vice versa.
You need to obtain a table in which:
the top-left cell contains ;
any two cells sharing a side contain different numbers.
Find the minimum number of such operations, choosing the row and column to delete optimally.
The first line contains two integers and (2 \leq n,m \leq 2000) — the number of rows and columns in the table.
Each of the next lines contains a string of length , consisting only of the characters and .
Print one integer — the minimum number of operations needed to change cell values.
Example 1
Example 2
Example 3
In the first example, deleting the second row and the second column leaves a table with rows 01 and 10. No cell values need to be changed.
In the second example, you can delete the third row and the fifth column. In the remaining table, it is enough to change the cell in the third row and the first column from to . It is impossible to obtain the required table without changing any cell values.
In the third example, no matter which row and column are deleted, a single cell containing remains. Its value must be changed to .
points — n,m \leq 20.
points — \min(n,m) \leq 20.
points — no additional constraints.