#t344. 字符数
字符数
Count of Letters
Problem Background
Special for beginners, ^_^
Problem Description
You are given an uppercase letter matrix of size . Starting from the top-left corner, you may move up, down, left, or right, and you may not step onto a letter you have already visited. What is the maximum number of distinct letters you can visit?
Input Format
The first line contains the number of rows and the number of columns of the letter matrix, with .
Then lines follow, each containing a row of the -column letter matrix.
Output Format
The maximum number of distinct letters that can be visited.
Sample Input
3 6
HFDFFB
AJHGDH
DGAGEH
Sample Output
6
Constraints
1s, 1024KiB for each test case.