#include <iostream>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int h,w;
char f[100][100];
int di[4] = {0,0,1,-1};
int dj[4] = {1,-1,0,0};

int dfs(int i,int j,char c){
	f[i][j] = 0;
	rep(k,4){
		int ni = i + di[k], nj = j + dj[k];
		if(0<=ni && ni<h && 0<=nj && nj<w && f[ni][nj]==c)dfs(ni,nj,c);
	}
}

int main(void){
	while(cin>>h>>w && (h || w)){
		int count = 0;
		rep(i,h)rep(j,w)cin>>f[i][j];
		rep(i,h)rep(j,w){
			if(f[i][j] != 0){
				dfs(i,j,f[i][j]);
				count++;
			}
		}
		cout<<count<<endl;
	}

	return 0;
}