#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

typedef pair<int,int> mypair;
int h,w;
string bd[101];

void chil(int y, int x){
int	dx[]={1,-1,0,0};
int	dy[]={0,0,1,-1};
char mrk = bd[y][x];
	stack< mypair > que;
	que.push(mypair(y,x));
	while(!que.empty()){
		int cy = que.top().first;
		int cx = que.top().second;
		que.pop();
		if(bd[cy][cx] == 'C')  continue;
		if(bd[cy][cx] == mrk ) bd[cy][cx] = 'C';
		rep(i,4){
			if(cy+dy[i] < 0 || cy+dy[i] >= h) continue;
			if(cx+dx[i] < 0 || cx+dx[i] >= w) continue;
			if(bd[cy+dy[i]][cx+dx[i]] == mrk ){
				que.push(mypair(cy+dy[i], cx+dx[i]));
			}
		}
	}
//	cout << cnq  << endl;
}


int main(void){

string ws;
	
	while( cin >> h >> w){
		if(h==0 && w==0 || cin.eof()) break;
		rep(i,h)  cin >> bd[i];
		
		int cnt = 0;
		rep(i,h) rep(j,w){
			if(bd[i][j]=='#' || bd[i][j]=='*' || bd[i][j]=='@'){
				cnt++;
				chil(i, j);
			}
		}
		cout << cnt << endl;
//		rep(i,h){ rep(j,w) cout << bd[i][j]; cout << endl; }
	}
	return 0;
	
}