P15938 [HackerEarth] You will be given a grid of numbers of size r by c (r-rows,c-columns). And you have to find the length of longest L that can be formed by same numbers. L shape will be one vertical line,
普及
题目描述

You will be given a grid of numbers of size r by c (r-rows,c-columns). And you have to find the length of longest L that can be formed by same numbers. L shape will be one vertical line,and from the bottom most point one horizontal line towards the right.

Length of L= No of elements in the shape formed.

Lets say the grid is of size 4 by 4 :

1 2 3 4
5 6 7 8
5 6 6 7
5 5 5 7

Here the longest L is of size 5 and of the element 5.

Note:
L can contain even a single element in horizontal or vertical line.

Input:

First line will contain two space separated integers r and c. Followed by r lines containing c space separated integers(Xij) in each line

Output:

Print the length of longest L possible

Constraints:

1 ≤ r , c ≤ 10^3

1 ≤ Xij ≤ 10^5

SAMPLE INPUT
4 4
1 2 3 4
5 6 7 8
5 6 6 7
5 5 5 7

SAMPLE OUTPUT
5

输入格式

见题面

输出格式

见题面

样例输入
2 5 1 1 1 5 5 6 6 6 6 5
样例输出
7