#include <bits/stdc++.h>

using namespace std;

int H, W;
char MapData[100][100];

void solve(char c, int row, int col) {
	int currentRow, currentCol;
	int dx[] = {0,1,0,-1};
	int dy[] = {1,0,-1,0};

	MapData[row][col] = 0;
	for (int i = 0; i < 4; i++) {
		currentRow = row + dx[i];
		currentCol = col + dy[i];
		
		if (currentRow<0 || currentRow>H - 1 || currentCol<0 || currentCol>W - 1) {
			continue;
		}
		if (MapData[currentRow][currentCol] == c) {
			solve(c, currentRow, currentCol);
		}
	}
}


int main() {
	int cnt;

	while (cin >> H >> W, H) {
		memset(MapData, 0, sizeof(MapData));
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >>MapData[i][j];
			}
		}
		cnt = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				switch (MapData[i][j])
				{
				case '@':cnt++; solve('@',i,j); break;
				case '#':cnt++; solve('#',i,j); break;
				case '*':cnt++; solve('*',i,j); break;
				default :break;
				}
			}
		}
		cout << cnt << endl;
	}

	return 0;
}
