#include <iostream>

using namespace std;

int H, W;
int m[100][100];

void del(int x, int y, int k) {
	if (x < 0 || x >= W || y < 0 || y >= H) return;
	if (m[y][x] != k) return;

	m[y][x] = 0;

	del(x+1, y, k);
	del(x-1, y, k);
	del(x, y+1, k);
	del(x, y-1, k);
}

int main() {
	while (cin >> H >> W, H || W) {
		for (int y = 0; y < H; ++y) {
			string str; cin >> str;
			for (int x = 0; x < W; ++x)
				m[y][x] =
					  str[x] == '#' ? 1
					: str[x] == '@' ? 2
					: str[x] == '*' ? 3
					: 0
					;
		}

		int ans = 0;
		for (int y = 0; y < H; ++y)
			for (int x = 0; x < W; ++x)
				if (m[y][x]) {
					++ans;
					del(x, y, m[y][x]);
				}


		cout << ans << endl;
	}
}