#include<iostream>

using namespace std;

char ban[101][101];

int cont = 0;
int h, w;

void saiki(int y, int x, char moji)
{
	ban[y][x] = '0';
	/*
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << ban[i][j] << flush;
		}
		cout << endl;
	}
	
	getchar();
	
	cout << endl;
	*/
	if(ban[y+1][x] == moji){
		saiki(y+1,x,moji);
	}
	if(ban[y-1][x] == moji){
		saiki(y-1,x,moji);
	}
	if(ban[y][x+1] == moji){
		saiki(y,x+1,moji);
	}
	if(ban[y][x-1] == moji){
		saiki(y,x-1,moji);
	}

}



int main()
{
	for(;;){
		
		cin >> h >> w;
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				ban[i][j] = '0';
			}
		}
		
		cont = 0;
		
		
		if(h == 0){
			break;
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> ban[i][j];
			}
		}
		
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(ban[i][j] != '0'){
					saiki(i,j,ban[i][j]);
					cont++;
				}
			}
		}
		cout << cont << endl;
	}
}