#include <cstdio>

int H, W;
char field[101][101];

void rec(int i, int j, char c){
	field[i][j] = '.';

	if (field[i + 1][j] == c && i + 1 < W) rec(i + 1, j, c);
	if (field[i - 1][j] == c && i - 1 > -1) rec(i - 1, j, c);
	if (field[i][j + 1] == c && j + 1 < H) rec(i, j + 1, c);
	if (field[i][j - 1] == c && j - 1 > -1) rec(i, j - 1, c);
}

int main(){
	int count = 0;
	while (1){
		count = 0;
		scanf("%d %d", &H, &W);
		//??????????????? H >= 0 && W >= 0	??????
		if (H + W == 0) break;
		for (int i = 0; i < H; i++){
			scanf("%s", &field[i]);
		}

		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if (field[i][j] != '.'){
					rec(i, j, field[i][j]);
					count++;
				}
			}
		}
		printf("%d\n", count);
	}
		
	return 0;
}