Time limit
2s
Memory limit
256 MB
A board has R rows and C columns. Each cell contains one uppercase English letter. A piece starts in the upper-left cell, row 1 and column 1.
The piece may move to one vertically or horizontally adjacent cell. It may enter a cell only if that cell's letter is different from every letter on the cells visited so far. In other words, the path cannot contain the same letter twice.
Find the maximum number of cells the piece can visit, including the starting cell.
The first line contains R and C, separated by a space. (1≤R,C≤20)
Each of the next R lines contains C uppercase English letters with no spaces, describing the board.
Print the maximum number of cells the piece can visit.