eolymp
bolt
Try our new interface for solving problems
Problems

Attacking rooks

Attacking rooks

Chess inspired problems are a common source of exercises in algorithms classes. Starting with the well known 8 - queens problem, several generalizations and variations were made. One of them is the n-rooks problem, which consists of placing n rooks in an n by n chessboard in such a way that they do not attack each other.

Professor Anand presented the n-rooks problem to his students. Since rooks only attack each other when they share a row or column, they soon discovered that the problem can be easily solved by placing the rooks along a main diagonal of the board. So, the professor decided to complicate the problem by adding some pawns to the board. In a board with pawns, two rooks attack each other if and only if they share a row or column and there is no pawn placed between them. Besides, pawns occupy some squares, which gives an additional restriction on which squares the rooks may be placed on.

Given the size of the board and the location of the pawns, tell Professor Anand the maximum number of rooks that can be placed on empty squares such that no two of them attack each other.

Input

The first line contains an integer n (1n100) representing the number of rows and columns of the board. Each of the next n lines contains a string of n characters. In the i-th of these strings, the j-th character represents the square in the i-th row and j-th column of the board. The character is either "." (dot) or the uppercase letter "X", indicating respectively an empty square or a square containing a pawn.

Output

Output a line with an integer representing the maximum number of rooks that can be placed on the empty squares of the board without attacking each other.

Time limit 1 second
Memory limit 128 MiB
Input example #1
1
X
Output example #1
0
Input example #2
5
X....
X....
..X..
.X...
....X
Output example #2
7
Input example #3
4
....
.X..
....
....
Output example #3
5
Source 2013 South America, Latino America, Problem A