#1775. [Usaco2017 Open]Where

[Usaco2017 Open]Where

Description

给出一个N*N的只含有A..Z的矩阵,一个合法的子矩阵定义为:只出现了两种不同的字符,其中一种字符的连通块

数量为1,另一种字符的连通块数量大于1。两个格子有公共边则它们连通。求不被其它任何合法的子矩阵所包含的

合法的子矩阵数量

Format

Input

The first line of input contains N

, the size of the grid (1≤N≤20). The next N lines describe the image, each consisting of N

characters.

Output

Print a count of the number of PCLs in the image.

Samples

4
ABBC
BBBC
AABB
ABBC
2

In this example, the two PCLs are the rectangles with contents
ABB
BBB
AAB
ABB

and

BC
BC
BB
BC