#STSC1B. [STSC OI - 1B] 城墙 (walls)

[STSC OI - 1B] 城墙 (walls)

Description

In the ruins, traces of war remain, along with scattered remnants of walls and towers. These structures were once connected, but the war has fragmented them.

To restore them, we first need to determine how many sections the walls are divided into. Here, walls and towers are considered as one entity. Given a map, your task is to calculate how many separate sections the wall is divided into.

Input

Line 11: Two positive integers n,mn,m, indicating the map has nn rows and mm columns.

Line 2n+12 \sim n+1: Input a nn-row by mm-column map consisting only of the characters # and .. # represents walls or towers, while . represents empty space.

Structures shaped like the following are considered a single connected section:

#.
.#

Output

Output a natural number ss, representing the number of sections the wall is divided into.

4 5
#...#
##..#
...#.
#....
3

Hint

For 100%100\% of the data, 2n,m502 \le n,m \le 50.

【Sample #1 Explanation】

The map contains three sections:

  1. Top-left section:
#.
##
  1. Top-right section:
.#
.#
#.
  1. Bottom-left section:
#