#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
const int maxn = 20;
char farm[maxn][maxn];
int h, w;
int ans;
void dfs(int x, int y, char c) {
	farm[x][y] = 'x';
	for (int dx = -1; dx <= 1; dx++) {
		for (int dy = -1; dy <= 1; dy++) {
			if (dx * dy == 0) {
				int nx = x + dx, ny = y + dy;
				if (0 <= nx && nx < w && 0 <= ny && ny < h && farm[nx][ny] == c) {
					dfs(nx, ny, c);
				}
			}
		}
	}
}


int main() {
	while (scanf("%d%d", &h, &w) != EOF) {
		if (h == 0 || w == 0) break;
		ans = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> farm[i][j];
			}
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (farm[i][j] != 'x') {
					dfs(i, j, farm[i][j]);
					++ans;
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}



