A Christmas Carol 4

View as PDF

Submit solution


Points: 7
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

It is the night before Christmas and bitter old Ebenezer Scrooge has banished away the Ghost of Christmas Present.
However, the visits from the spirits have made him somewhat hesitant.
The last push to change Ebenezer Scrooge arrives in the form of the Ghost of Christmas Future.
He shows the old man one last vision, this time of a Christmas yet to come.
They arrive at Ebenezer Scrooge's funeral, where nobody weeps and nobody is glum.
Nobody will miss old Ebenezer Scrooge, not even the few who showed up.
How many people did show up exactly?

Ebenezer Scrooge's funeral is only attended by business associates who only came because they were promised free lunch. The businessmen each wear a black rectangular hat. Looking from above, each black rectangle that can be seen must be a person and any other black figure must be another object. Black cells above, below, to the left and to the right are considered all part of one object. Given a bird's eye view of Ebenezer Scrooge's funeral represented as a grid, determine how many people attended.

Input Specification

The first line of input contains r (3 \le r \le 1000) representing the number of rows in the grid.
The second line of input contains c (3 \le c \le 1000) representing the number of columns in the grid.
The next r lines each contain c characters. Each character is either a . or # character. # means this cell is black in color and . means it is not black.

Output Specification

Using the grid representing Ebenezer Scrooge's funeral, determine the number of people there by counting the black rectangles.

Sample Input

7
9
###......
###......
.........
.....###.
..#......
..##...#.
.........

Sample Output

3

Comments

There are no comments at the moment.