After finishing one task at work, Bob is getting bored. So he decides to count some patterns in the -pixel-high by -pixel-wide computer screen his employer gave him. Each pixel is either yellow (lit) or black (unlit).
Bob thinks a rectangle of pixels, with both dimensions at least , is ugly if its first and last rows are identical and its first and last columns are identical. (Note: this definition is the same as the one in Problem 5.) For example, the following rectangles are ugly:
Please help Bob count the number of ugly sub-rectangles in the screen!
Constraints
Subtask 1 [10%]
Subtask 2 [20%]
Subtask 3 [70%]
No additional constraints.
Input Specification
The first line contains two space-separated integers, and .
The next lines each contain a string of characters—Y
for yellow and B
for black—representing the colours of the pixels on the screen.
Output Specification
Output one integer, the number of ugly sub-rectangles.
Sample Input
3 3
BYB
YYY
BYB
Sample Output
1
Comments