#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
char field[101][101];
int dx[] = {1,-1,0,0},dy[] = {0,0,1,-1};
void func(int x,int y,char f){
	if(field[y][x] != f)return ;
	else field[y][x] = 0;
	for(int i = 0; i < 4; i++){
		int nx = x + dx[i],ny = y + dy[i];
		func(nx,ny,f);
	}
}
int main(){
	int h,w;
	while(cin >> h >> w,(h|w)){
		memset(field,0,sizeof(field));
		for(int i = 0; i < h; i++){
			scanf("%s",field[i]);
		}
		int cnt = 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(field[i][j] == 0)continue;
				cnt++;
				func(j,i,field[i][j]);
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}