#include <iostream>
#include <string>

using namespace std;

int h, w, f[100][100];
string s[100];
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};

void dfs(int y,int x,char c){
	int i;
	f[y][x] = 1;
	for(i = 0;i < 4;i++){
		if(y + dy[i] >= 0 && y + dy[i] < h && x + dx[i] >= 0 && x + dx[i] < w && c == s[y + dy[i]][x + dx[i]] && !f[y + dy[i]][x + dx[i]]){
			dfs(y + dy[i],x + dx[i],c);
		}
	}
}


int main(void){
	int i, j, ans;
	while(1){
		cin >> h >> w;
		if(h == 0 && w == 0) break;
		ans = 0;
		scanf("%*c");
		for(i = 0;i < h;i++){
			getline(cin,s[i]);
			for(j = 0;j < w;j++)
				f[i][j] = 0;
		}
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				if(!f[i][j]){
					dfs(i,j,s[i][j]);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}