#include <cstdio>
#include <queue>

using namespace std;

const int MAX_H = 101;
const int MAX_W = 101;
int H, W;
char blocks[MAX_H][MAX_W];

int init() {
	scanf("%d%d", &H, &W);

	if (H == 0 && W == 0) return -1;
	
	for (int i = 0; i < H; i++) {
		scanf("%s", blocks[i]);
	}
	
	return 0;
}

void fill(int row, int col) {
	char type = blocks[row][col];
	
	queue<pair<int, int>> que;
	que.emplace(row, col);
	
	int di[] = {1, -1, 0, 0};
	int dj[] = {0, 0, 1, -1};
	
	while (!que.empty()) {
		auto data = que.front();
		que.pop();
		int i = data.first;
		int j = data.second;
		blocks[i][j] = '.';
		
		for (int k = 0; k < 4; k++) {
			int ti = i + di[k];
			int tj = j + dj[k];
			
			if (0 <= ti && ti < H && 0 <= tj && tj < W) {
				if (blocks[ti][tj] == type) {
					que.emplace(ti, tj);
				}
			}
		}
	}
}

void solve() {
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (blocks[i][j] != '.') {
				fill(i, j);
				ans++;
			}
		}
	}
	printf("%d\n", ans);
}

int main() {
	while (!init()) {
		solve();
	}
}