#include <bits/stdc++.h>
using namespace std;

int h, w;
char field[110][110];
bool j = true;

int dfs(int p, int q, char c) {
	field[p][q] = 'a';
	int dx[4] = { 0, 0, 1, -1 };
	int dy[4] = { 1, -1, 0, 0 };
	for (int i = 0; i < 4; i++) {
		int nx = p + dx[i];
		int ny = q + dy[i];
		if (0 <= nx && nx < h && 0 <= ny && ny < w && field[nx][ny] == c) {
			dfs(nx, ny, c);
		}
	}
	return 0;
}

int main() {
	while (j) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			return 0;
			j = false;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> field[i][j];
			}
		}
		int ans = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (field[i][j] != 'a') {
					dfs(i, j, field[i][j]);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}
