//status is WA.
#include <iostream>

using namespace std;

int W, H;
string field[100];
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

void dfs(int x, int y, char c) {
	field[x][y] = '.';

	for(int i = 0; i < 4; i++) {
			int nx = x + dx[i], ny = y + dy[i];
			if(0 <= nx && nx < W && 0 <= ny && ny < H && field[nx][ny] == c) {
				dfs(nx, ny, c);
			}
	}
}

int main() {
	int result = 0;

	  for(;cin >> W >> H, W || H;) {
		for(int i = 0; i < H; i++) {
			cin >> field[i];
		}

		for(int i = 0; i < W; i++) {
			for(int j = 0; j < H; j++) {
				if(field[i][j] == '@' || field[i][j] == '#' || field[i][j] == '*') {
					dfs(i, j, field[i][j]);
					result++;
				}
			}
		}
	cout << result << endl;
	result = 0;
	}
	return 0;
} 