#include<iostream>
#include<cstring>
using namespace std;
int h,w;
char a[101][101];

void dfs(int c, int b, char sign){
	int y = c-1;
	int x = b;
	if(y>=0 && x>=0 && y<h && x<w && a[y][x] == sign){
		a[y][x] = '!';
		dfs(y, x, sign);
	}
	y = c+1;
	x = b;
	if(y>=0 && x>=0 && y<h && x<w && a[y][x] == sign){
		a[y][x] = '!';
		dfs(y, x, sign);
	}
	y = c;
	x = b - 1;
	if(y>=0 && x>=0 && y<h && x<w && a[y][x] == sign){
		a[y][x] = '!';
		dfs(y, x, sign);
	}
	y = c;
	x = b + 1;
	if(y>=0 && x>=0 && y<h && x<w && a[y][x] == sign){
		a[y][x] = '!';
		dfs(y, x, sign);
	}
	
	
}



int main()
{	
	//freopen("in.txt", "r", stdin);
	while(cin >> h >> w){
		if(h == 0 && w == 0){
			break;
		}
		memset(a,127,sizeof(a));
		for(int i = 0; i<h; i++){
			for(int j = 0; j<w; j++){
				cin >> a[i][j];
			}
		}
		int count = 0;
		for(int i = 0; i<h; i++){
			for(int j = 0; j<w; j++){
				if(a[i][j] != '!'){
					dfs(i, j, a[i][j]);
					count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
} 
