UT Invitational Programming Contest Spring 2020

Start

2020-05-02 09:00 AKDT

UT Invitational Programming Contest Spring 2020

End

2020-05-02 14:00 AKDT
The end is near!
Contest is over.
Not yet started.
Contest is starting in -181 days 10:33:13

Time elapsed

5:00:00

Time remaining

0:00:00

Problem H
Safe Squares

Penny is a young, enthusiastic pawn with significant ambitions. She hopes to improve her currently measly ranking and one day become queen of her entire chess board! Unfortunately, the current queen prefers the pawns of her kingdom do nothing but her bidding and views Penny’s ambitions as a potential source of rebellion. She sends her loyal rooks onto the board to capture Penny and bring her before the royal court to face punishment.

Penny obviously does not want to be captured by the queen’s rooks, but she does not know the safe spots on the board to escape to. If she goes to any square that is in the same row or same column as a rook, the rook will capture her! Given the locations of all the rooks, tell Penny how many squares there are on the chess board where she would be safe from the rooks!

Input

The input consists of $8$ lines that each contain exactly $8$ characters. Each line represents one row of the chessboard, and contains only R and . characters. The R characters are squares which contain a rook and the . characters represent empty squares.

Output

Print the number of squares on the chess board where Penny is safe from the rooks: where no rook is in the same row or column as the square. Note that there may be no safe squares (because the entire board is filled with rooks, or because every empty square is in the same row or column as a rook) in which case you should print 0.

Sample Input 1 Sample Output 1
...R....
..R..R..
R.....R.
....R...
.R.....R
........
.....R..
R.......
0
Sample Input 2 Sample Output 2
.R......
..R.....
........
........
........
........
........
........
36