#418. B - Blank Bingo(空白宾果)

B - Blank Bingo(空白宾果)

Problem Statement

There is a 5×55\times 5 grid, and some of the cells are marked.

The current state of the grid is given by strings S1,S2,S3,S4,S5S_1,S_2,S_3,S_4,S_5 of length 55 consisting of o and .. A cell is marked when its character is o, and unmarked when it is ..

Find the minimum number of additional marks needed to achieve a bingo.

A bingo is achieved when all 5 cells in any row, column, or one of the two main diagonals are marked.

Input

Five lines, each containing a five-character string using only o and ..

Output

Print the minimum number of additional marks.

Samples

.o..o
..oo.
.o..o
o.o..
o..oo
2
o..oo
...o.
o.ooo
oo.o.
.o.oo
0
o..o.
.o...
..o.o
..o..
o...o
1