To celebrate Halloween, you have decided to hold an art contest! A drawing is a grid of pixels with #
and .
characters. #
can be thought of as a black pixel, and .
can be thought of as a white pixel. It is guaranteed that the drawing will be framed with a single layer of black pixels. For more details, refer to the input specification section.
As the head judge of this art contest, you have decided that the winner of the art contest will be the drawing with the most number of pumpkins. Given a drawing, can you count the number of pumpkins in it?
A pumpkin can come in various positive integer sizes. Specifically a pumpkin of size #
, .
, and
characters. Here,
can be thought of as a transparent pixel. A pumpkin of size
A subgrid can be defined by
The
- The first row consists of (from left to right)
transparent pixels, white pixels, and transparent pixels. - The next
rows each consists of transparent pixels, white pixel, black pixel, white pixel, and transparent pixels. - The next row consists of
white pixels, black pixel, and white pixels. - The next
rows each consists of white pixel, black pixels, and white pixel. - The last row consists of
white pixels.
Note that
Below is a pumpkin of size
...
.#.
.......#.......
.#############.
.#############.
.#############.
.#############.
.#############.
...............
Constraints
For this question, Python users are recommended to use PyPy over CPython.
Input Specification
The first line of input contains a single integer,
The next #
or .
.
It is guaranteed that all characters in the first and last rows of the drawing, as well as the first and last columns, consist solely of #
.
Output Specification
This problem is graded with an identical
checker. This includes whitespace characters. Ensure that every line of output is terminated with a \n
character and that there are no trailing spaces.
Output a single integer, the total number of pumpkins in the drawing.
Sample Input 1
12
########################
#......................#
#.......#..............#
#.......#..............#
#.#############........#
#.#############........#
#.#############...#....#
#.#############.#####..#
#.#############.#####..#
#......................#
#......................#
########################
Sample Output 1
2
Sample Input 2
13
##########################
#........................#
#.........#.......#......#
#.......#####.....#......#
#.......#####...#####....#
#......#........#####....#
#....#####...............#
#....#####.....#.........#
#...........#######......#
#...........#.....#......#
#...........#######......#
#........................#
##########################
Sample Output 2
0
Comments