#include <iostream>
using namespace std;

char C[102][102];

int Check(int x, int y, char c){
	if(C[x][y] != c){
		return 0;
	}
	C[x][y] = '.';
	Check(x  ,y-1,c);
	Check(x+1,y  ,c);
	Check(x  ,y+1,c);
	Check(x-1,y  ,c);
}

int main(){
	int W,H;
	while(cin >> W >> H){
		if(W == 0 && H == 0){
			break;
		}
		for(int x = 1;x <= W;x++){
			for(int y = 1;y <= H;y++){
				cin >> C[x][y];
			}
		}
		int cnt = 0;
		for(int x = 1;x <= W;x++){
			for(int y = 1;y <= H;y++){
				if(C[x][y] != '.'){
					cnt++;
					Check(x,y,C[x][y]);
				}
			}
		}	
		cout << cnt << endl;
	}
	return 0;
}
