Description
JOI-kun is playing with a drawing program.
In the drawing program, you can draw a picture on a rectangular grid of $H$ rows vertically and $W$ columns horizontally. Each cell is assigned a color, and colors are represented by integers between $1$ and $10^9$, inclusive.
The cell at the $i$-th row from the top ($1 \le i \le H$) and the $j$-th column from the left ($1 \le j \le W$) is called cell $(i,j)$. Currently, the color of cell $(i,j)$ is $A_{i,j}$.
The set of cells that can be reached from cell $(i,j)$ by repeatedly moving to an edge-adjacent cell without entering any cell of a color different from that of cell $(i,j)$ is called the region of cell $(i,j)$ here.
The drawing program has a function called flood fill. With this function, when a certain cell $(x,y)$ ($1 \le x \le H$, $1 \le y \le W$) and a color $c$ ($1 \le c \le 10^9$) are specified, the colors of all cells contained in the region of cell $(x,y)$ change to $c$.
JOI-kun chooses a certain cell $(x,y)$ and a color $c$, and uses flood fill specifying that cell and color exactly $1$ time. The number of cells contained in the region of cell $(x,y)$ after using flood fill will be JOI-kun's score.
Write a program to find the maximum possible score that JOI-kun can achieve.
Input
The input is given in the following format:
H W
A_{1,1} A_{1,2} \ldots A_{1,W}
A_{2,1} A_{2,2} \ldots A_{2,W}
:
A_{H,1} A_{H,2} \ldots A_{H,W}Output
Output on $1$ line the maximum possible score that JOI-kun can achieve.
Constraints
- $1 \le H \le 500$.
- $1 \le W \le 500$.
- $1 \le A_{i,j} \le 10^9$ ($1 \le i \le H$, $1 \le j \le W$).
- All input values are integers.
Subtasks
- ($9$ points) $H = 1$.
- ($32$ points) $H \le 30$, $W \le 30$, $A_{i,j} \le 5$ ($1 \le i \le H$, $1 \le j \le W$).
- ($18$ points) $H \le 30$, $W \le 30$.
- ($10$ points) $A_{i,j} \le 2$ ($1 \le i \le H$, $1 \le j \le W$).
- ($31$ points) No additional constraints.
Sample
Sample Input 1
4 4 1 2 3 1 2 2 3 1 1 2 3 1 3 3 2 2
Sample Output 1
9
Initially, there are $4$ cells contained in the region of cell $(2,2)$, which are cells $(1,2), (2,1), (2,2), (3,2)$. Therefore, if flood fill is used specifying cell $(2,2)$ and color $3$, the colors of these $4$ cells change to $3$ as shown in the figure below.

After using flood fill, there are $9$ cells contained in the region of cell $(2,2)$, which are cells $(1,2), (1,3), (2,1), (2,2), (2,3), (3,2), (3,3), (4,1), (4,2)$. Thus, JOI-kun's score becomes $9$.
Since JOI-kun's score cannot be $10$ or more, output $9$.
This input satisfies the constraints of Subtasks $2, 3, 5$.
Sample Input 2
2 10 1 2 2 1 3 3 3 3 1 1 1 1 1 1 1 1 1 3 3 3
Sample Output 2
18
This input satisfies the constraints of Subtasks $2, 3, 5$.
Sample Input 3
5 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Sample Output 3
25
This input satisfies the constraints of Subtasks $2, 3, 4, 5$.