#t447. 细胞

细胞

Cells

Problem Background

Special for beginners, ^_^

Problem Description

A rectangular array consists of digits 00 to 99. Digits 11 to 99 represent cells. A cell is defined as: if the digit adjacent (up, down, left, right) to a cell digit is also a cell digit, they belong to the same cell. Find the number of cells in the given rectangular array. For example:

The array:

4 10
0234500067
1034560500
2045600671
0000000089

has 44 cells.

Input Format

The first line is the number of rows nn and columns mm of the matrix;

The following is an n×mn\times m matrix.

Output Format

The number of cells.

Sample Input 1

4 10
0234500067
1034560500
2045600671
0000000089

Sample Output 1

4

Constraints

1≤n,m≤1001\le n,m\le 100. Time limit 1s, memory limit 1024KiB for each test case.