## DMOPC '20 Contest 5 P4 - Slacking Off

View as PDF

Points: 15 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

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:

#### 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