#include <iostream>
#include <cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
const int dx[] = { 1, 0, -1, 0 }, dy[] = { 0, 1, 0, -1 };

int cnt = 0;
int w, h;
char tab[101][101];

void dfs(char c, int x, int y){
	rep(i, 4){
		int nx = x + dx[i], ny = y + dy[i];
		if (nx >= 0 && nx < w&&ny >= 0 && ny < h&&tab[nx][ny] == c){
			tab[nx][ny] = '.';
			dfs(c, nx, ny);
		}
	}
}

int main(){
	while (1){
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		rep(i, h) rep(j, w) cin >> tab[i][j];
		rep(i, h){
			rep(j, w){
				if (tab[i][j] != '.'){
					cnt++;
					dfs(tab[i][j], i, j);
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}