#T344. 细胞
细胞
Description
A rectangular array consists of numbers from to . The numbers to 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 and columns of the matrix.
The following lines represent an matrix.
Output Format
The number of cells.
4 10
0234500067
1034560500
2045600671
0000000089
4 10
0234500067
1034560500
2045600671
0000000089