문제
Always known for being quite tech-savy, Farmer John is testing out his new automated drone-mounted cow locator camera, which supposedly can take a picture of his field and automatically figure out the location of cows. Unfortunately, the camera does not include a very good algorithm for finding cows, so FJ needs your help developing a better one.
The overhead image of his farm taken by the camera is described by an
For example, a rectangle with contents
AAAAA
ABABA
AAABBwould constitute a PCL, since the A's form a single contiguous region and the B's form more than one contiguous region. The interpretation is a cow of color A with spots of color B.
A region is "contiguous" if you can traverse the entire region by moving repeatedly from one cell in the region to another cell in the region taking steps up, down, left, or right.
Given the image returned by FJ's camera, please count the number of PCLs.
입력
The first line of input contains
출력
Print a count of the number of PCLs in the image.
예제
4
ABBC
BBBC
AABB
ABBC
2
In this example, the two PCLs are the rectangles with contents
ABB
BBB
AAB
ABBand
BC
BC
BB
BC