#include<iostream>
using namespace std;
#define MAX 101
int w,h;
char map[MAX][MAX];
int DX[] = {0,1,0,-1};
int DY[] = {-1,0,1,0};
int rec(int y,int x,char c){
	if(map[y][x] == '.')return 0;
	map[y][x] = '.';
	for(int i= 0;i < 4;i++){
		int nx = x + DX[i];
		int ny = y + DY[i];
		if(nx < 0 || nx >= w)continue;
		if(ny < 0 || ny >= h)continue;
		if(map[ny][nx] != c)continue;
		rec(ny,nx,c);
	}
	return 1;
}

int main(){
	while(true){
		cin >> h>>w;
		if(!(w||h))break;
		int ans = 0;
		for(int i=0; i < h;i++){
			cin >> map[i];
		}
		for(int i = 0; i < h;i++){
			for(int j = 0; j < w;j++){
				if(map[i][j] == '.')continue;
				ans += rec(i,j,map[i][j]);
			}
		}
		cout << ans<<endl;
	}
	return 0;
}