#include <stdio.h>

int H, W;
char map[100][100];

bool paint(int i, int j) {
	if (map[i][j] == ' ')return false;

	char data = map[i][j];
	map[i][j] = ' ';
	if (i>0 &&  data == map[i - 1][j])paint(i - 1, j);
	if (j>0 &&  data == map[i][j - 1])paint(i, j - 1);
	if (i <= H&&data == map[i + 1][j])paint(i + 1, j);
	if (i <= W&&data == map[i][j + 1])paint(i, j + 1);

	return true;
}

int main() {
	int num = 0;

	scanf("%d %d", &H, &W);
	for (int i = 0; i<W; i++) {
		scanf("%s", map[i]);
	}
	scanf("%d %d",&num,&num);

	for (int i = 0; i<H; i++) {
		for (int j = 0; j<W; j++) {
			if (paint(i, j))num++;
		}
	}

	printf("%d\n", num);
	return 0;
}