#include<iostream>
#include<vector>
#include<string>
using namespace std;

vector<string> farm(101);
vector< vector<int> > farmBuf(101, vector<int>(101));
int H, W;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void rec(char c, int y, int x) {
	int i, xx, yy;
	farmBuf[y][x] = 1;
	for (i = 0; i < 4; i++) {
		xx = x+dx[i]; yy = y+dy[i];
		if (xx<0||W<=xx||yy<0||H<=yy) continue;
		if (farm[yy][xx]==c && !farmBuf[yy][xx]) rec(c, yy, xx);
	}
	return;
}

int main()
{
	int i, j, count;
	while (cin>>H>>W, H||W) {
		for (i = 0; i < H; i++)
			for (j = 0; j < W; j++)
				farmBuf[i][j] = 0;
		for (i = 0; i < H; i++) cin>>farm[i];
		count = 0;
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if (!farmBuf[i][j]) {
					rec(farm[i][j], i, j);
					count++;
				}
			}
		}
		cout<<count<<endl;
	}

	return 0;
}