Moocryption#11166

Moocryption

1 second
128 megabytes
Very easy

Unbeknownst to many, cows are quite fond of puzzles, particularly word puzzles. Farmer John's cows have recently created a fun "word finder" puzzle. An example of such a puzzle is:

\begin{array}{llllll} U&S&O&P&E&N\\ O&O&M&A&B&O\\ M&O&O&M&X&O\\ P&Q&M&R&O&M \end{array}

Being cows, their only word of interest is , which can appear in the word finder in many places, either horizontally, vertically, or diagonally. The example above contains occurrences of .

Farmer John is also a fan of word puzzles. Since the cows do not want him to solve their word finder before they have a chance to try it themselves, they have encrypted the puzzle using a "substitution cipher" that replaces each letter of the alphabet with a different letter.

For example, might be mapped to , might be mapped to , and so on. No letter is mapped to itself, and no two letters are mapped to the same letter, since otherwise the decryption would be ambiguous.

Unfortunately, the cows have lost track of the substitution cipher used to encrypt their puzzle. Please help them determine the maximum possible number of MOOs that could exist in the puzzle for some valid choice of substitution cipher.

Input

The first line contains two integers and m~(1 \le n, m \le 50), describing the number of rows and columns of the puzzle.

The next lines each contain characters, describing one row of the encrypted puzzle. Each character is an uppercase letter in the range .

Output

Print the maximum possible number of s that could be contained in the puzzle after decrypting it with an appropriate substitution cipher.

Examples

The example above is the same puzzle as at the beginning of the problem statement, but with a substitution cipher applied. In this example, the letters and have been replaced by and , respectively.

Example 1

Loading
Loading