#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;
int W, H;
char map[105][105];
bool vis[105][105];

void solve(int x, int y, char fruit) {
	vis[x][y] = true;
	int dx[4] = {0, -1, 0, 1};
	int dy[4] = {1, 0, -1, 0};
	int i, j;
	for (i = 0; i < 4; i++) {
		int x1, y1;
		x1 = x + dx[i];
		y1 = y + dy[i];
		if (x1 < H && y1 < W && x1 >= 0 && y1 >= 0 
			&& vis[x1][y1] == false && map[x1][y1] == fruit)
			solve(x1, y1, fruit);
	}
}

int main() {
	while (scanf("%d%d", &H, &W) == 2) {
		if (W == 0 && H == 0) break;
		getchar();
		int i, j;
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				scanf("%c", &map[i][j]);
			}
			getchar();
		}	
		memset(vis, false, sizeof(vis));
		int res = 0;
		for (i = 0; i < H; i++)
		for (j = 0; j < W; j++)
		if (vis[i][j] == false) {
			solve(i, j, map[i][j]);
			res++;
		}
		cout << res << endl;
	}
	return 0;
}