George has recently enrolled in a Kabbalah seminar, where a few cultured savants debate on the concealed wisdom of the Bible. In particular, their favorite hobby is searching the Bible for long sequences of equal letters.
Firstly, the seminar master selects an rectangle of characters from the holy scriptures. Afterwards, the adepts search in all directions (horizontal, vertical and diagonal) for contiguous sequences of equal letters and the longer the sequence found, the greater the glory for the finder.
Task
Help George prove his wisdom by finding the longest sequence of equal letters!
Input data
The first line contains two integers and . Other lines follow, each containing a string consisting of lowercase letters from a
to z
(translated from the Hebrew alphabet).
Output data
You need to write a single line with an integer: the longest sequence of equal letters present in the bible fragment.
Constraints and clarifications
- is a lowercase letter from
a
toz
for each , .
# | Points | Constraints |
---|---|---|
1 | 5 | Examples. |
2 | 25 | |
3 | 40 | |
4 | 30 | No additional constraints. |
Example 1
stdin
4 6
uieiki
zqnitz
chquth
keinoi
stdout
2
Explanation
The longest sequence consists of vertical letters i
.
Example 2
stdin
7 5
fjqhr
aqnrb
baqah
zanqi
oahqq
rovna
zgpao
stdout
4
Explanation
The longest sequence consists of diagonal letters q
.