Hello. There is a task "Military Base" :
An image of a top-secret military base of an alleged enemy was obtained from a spy satellite in a certain wave range. The base is located on Antarctica, all buildings on it are carved from ice cubes and have a square shape in the photo and do not have common fragments of walls of non-zero length (apparently, this was done in order to disguise from locators operating in the infrared spectrum). Thanks to the skill of the operators, it turned out that the walls of different buildings are parallel to the photo borders.
In order to make an urgent report to the command, you need to know how many buildings are located at the base. Write a program that will do this.
Input data
The first line of the input file INPUT.TXT contains the numbers N and M (1 <= M, N <= 500) - the size of the photo in pixels vertically and horizontally. The following N lines contain M characters each: the '.' corresponds to empty space, '#' - to the element of construction.
Output
In the output file OUTPUT.TXT output a single number - the number of buildings on the base.
There are no ideas how to write it. Is it appropriate to search in width? Write the implementation of the search in width and depth in a two-dimensional array. Thank.