#abc193f. [abc193_f]Zebraness

[abc193_f]Zebraness

Problem Statement

We have a grid with NN horizontal rows and NN vertical columns.
Let (i,j)(i, j) denote the square at the ii-th row from the top and jj-th column from the left. A character ci,jc_{i,j} describes the color of (i,j)(i, j).
B means the square is painted black; W means the square is painted white; ? means the square is not yet painted.

Takahashi will complete the black-and-white grid by painting each unpainted square black or white.
Let the zebraness of the grid be the number of pairs of a black square and a white square sharing a side.
Find the maximum possible zebraness of the grid that Takahashi can achieve.

Constraints

  • 1N1001 ≤ N ≤ 100
  • ci,jc_{i, j} is B, W, or ?.

Input

Input is given from Standard Input in the following format:

NN c1,1dotsc1,Nc_{1,1} \\dots c_{1,N} hspace20ptvdots\\hspace{20pt}\\vdots cN,1dotscN,Nc_{N,1} \\dots c_{N,N}

Output

Print the answer.


Sample Input 1

2
BB
BW

Sample Output 1

2

We have two pairs of a black square and a white square sharing a side: (1,2),(2,2)(1, 2), (2, 2) and (2,1),(2,2)(2, 1), (2, 2), so the zebraness of this grid is 22.


Sample Input 2

3
BBB
BBB
W?W

Sample Output 2

4

Painting (3,2)(3, 2) white makes the zebraness 33, and painting it black makes the zebraness 44.


Sample Input 3

5
?????
?????
?????
?????
?????

Sample Output 3

40