Because MCPT has stolen SAC's idea to sell hotdogs at food day, Zoe decides to bake cookies instead.
Currently, she has an baking sheet. This sheet can be thought of as a matrix of cells, with as the top-left cell and as the bottom-right.
Zoe has placed cookie dough on some cells and has just placed the sheet in the oven. However, she forgets that cookie dough expands when baking. A strange phenomenon happens as a result: if a cell not containing cookie dough is cardinally adjacent (horizontally or vertically) to at least two other cells containing cookie dough, the cookie dough will fill that cell after minute.
Fascinated, Zoe wonders how many cells contain cookie (not dough anymore!) if she bakes the cookies for minutes.
Constraints
For all subtasks,
Subtask 1 [25%]
Subtask 2 [75%]
No additional constraints.
Input Specification
The first line will contain , , and , space-separated.
The next lines will contain O
or .
characters, denoting whether there is cookie dough at that cell, or not, respectively.
Output Specification
Output a single integer on one line: how many cells contain cookie if she baked the cookies for minutes.
Sample Input 1
6 6 10
..O...
.....O
.OO...
......
.....O
....O.
Sample Output 1
11
Explanation for Sample Output 1
The following diagrams describe how the cookie dough expands after , , and minutes respectively. After three minutes the cookie dough no longer expands, and Zoe is left with cells containing cookie.
..O...
..O..O
.OO...
......
....OO
....OO
..O...
.OO..O
.OO...
......
....OO
....OO
.OO...
.OO..O
.OO...
......
....OO
....OO
Sample Input 2
3 2 1
.O
O.
O.
Sample Output 2
5
Comments
Since the original data were weak, a new test case has been added and all submissions have been rejudged.