# include<stdio.h>
# define max_M 100
# define max_N 100
char garden[max_M][max_N];
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,1,-1};
int r, c;

void dfs(int x, int y){
	char temp = garden[x][y];
	garden[x][y] = '.';
	for(int i=0;i<4;i++){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(0<=nx&&nx<r&&0<=ny&&ny<c&&garden[nx][ny]==temp){
			dfs(nx,ny);
		}
	}
	return;
}

int solve(){
	int res = 0;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			if(garden[i][j]!='.'){
				dfs(i,j);
				res += 1;
			}
		}
	}
	return res;
}

int main(){
	int res;
	while(scanf("%d%d",&r,&c)!=EOF&&r&&c){
		for(int i=0;i<r;i++){
			getchar();
			for(int j=0;j<c;j++){
				scanf("%c",&garden[i][j]);
			}
		}
		res = solve();
		printf("%d\n",res);
	}
	return 0;
}
