#include <cstdio>

using namespace std;

const int MAX_H = 100;
const int MAX_W = 100;
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];
	blocks[row][col] = '.';
	
	int di[] = {1, -1, 0, 0};
	int dj[] = {0, 0, 1, -1};
	
	for (int k = 0; k < 4; k++) {
		int ti = row + di[k];
		int tj = col + dj[k];
		
		if (ti < 0 || tj < 0 || ti >= H || tj >= W) continue;
		if (blocks[ti][tj] == type) {
			fill(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();
	}
}