#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

int farm[101][101];

void kubun(int k,int a,int b){
	farm[a][b]=0;
	if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b);
	if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b);
	if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1);
	if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1);
	return;
	
}
int main(){
	char c[101][101];
	int a,b;
	int h,w;
	int ans=0;
	while(1){
		ans=0;
		memset(farm,0,sizeof(farm));
		cin >> h >> w;
		if(h==0 && w==0)break;
		for(b=0;b<w;b++){
			cin >> c[b];
			for(a=0;a<h;a++){
				if(c[b][a]=='@')farm[a][b]=1;
				if(c[b][a]=='#')farm[a][b]=2;
				if(c[b][a]=='*')farm[a][b]=3;
				
			}
		}
		for(b=0;b<w;b++){
			for(a=0;a<h;a++){
				if(farm[a][b]==0);
				else{
					ans++;
					kubun(farm[a][b],a,b); 
				}
			}
		}
		cout<< ans << endl;
	}
	return 0;
}