// 2011/02/06 Tazoe

#include <iostream>
using namespace std;

void DFS(char farm[102][102], int H, int W, char fruit, int h, int w)
{
	if(farm[h][w]!=fruit)
		return;

	farm[h][w] = '/';

	DFS(farm, H, W, fruit, h  , w+1);
	DFS(farm, H, W, fruit, h+1, w  );
	DFS(farm, H, W, fruit, h  , w-1);
	DFS(farm, H, W, fruit, h-1, w  );
}

int main()
{
	while(true){
		int H, W;
		cin >> H >> W;
		if(H==0&&W==0)
			break;

		char farm[102][102];
		for(int h=0; h<H+2; h++)
			for(int w=0; w<W+2; w++)
				farm[h][w] = '-';

		for(int h=1; h<=H; h++)
			for(int w=1; w<=W; w++)
				cin >> farm[h][w];

		int cnt = 0;
		for(int h=1; h<=H; h++)
			for(int w=1; w<=W; w++)
				if(farm[h][w]!='/'){
					cnt++;
					DFS(farm, H, W, farm[h][w], h, w);
				}

		cout << cnt << endl;
	}

	return 0;
}