#T344. 细胞

细胞

Description

A rectangular array consists of numbers from 00 to 99. The numbers 11 to 99 represent cells. A cell is defined as follows: if the digits above, below, to the left, or to the right of a cell digit are also cell digits, they belong to the same cell. Given a rectangular array, determine the number of cells. For example, in the array:

4 10
0234500067
1034560500
2045600671
0000000089

Input Format

The first line contains the number of rows nn and columns mm of the matrix.
The following lines represent an n×mn \times m matrix.

Output Format

The number of cells.

4 10
0234500067
1034560500
2045600671
0000000089

4 10
0234500067
1034560500
2045600671
0000000089