Taeyang starts a game with $MN$ white and black stones placed on an $M\times N$ grid, as shown below.
For any stone $X$, the $4$ stones immediately above, below, to the left, and to the right of $X$ are called its neighbors. Taeyang may choose one stone and change its color. Its neighbors of the same original color also change to the new color. This continues repeatedly: neighbors of stones whose colors change also change color if they have the same original color.
For example, changing stone $A$ in the picture above to white turns the black stones forming the shape “ㄷ” white, as shown below.
Next, changing stone $C$ to white produces the following picture.
Then, changing stone $F$ to white and finally stone $E$ to white makes all stones white. Thus, all stones have become white after four color changes.
However, all stones can be made the same color with only two changes. First, changing stone $B$ to black produces the following picture.
Then, one can change stone $A$ to white to make all stones white, or change stone $D$ to black to make all stones black. Thus, two color changes suffice to make all stones the same color.
Given white and black stones on an $M\times N$ grid, write a program to find the minimum number of color changes needed to make all stones the same color.
Input
The first line contains two positive integers $M$ and $N$ describing the $M\times N$ grid, separated by a space. Both $M$ and $N$ are between $2$ and $100$, inclusive. Each of the following $M$ lines contains $N$ space-separated values describing one row of the grid: $0$ denotes a white stone and $1$ a black stone.
Output
Print on the first line the minimum number of color changes needed to make all stones the same color.
Examples
Input 1
5 6 1 1 0 1 0 0 1 0 0 1 1 1 1 1 0 1 1 1 0 0 0 0 0 0 1 1 1 0 1 1
Output 1
2