#include <stdio.h>
using namespace std;

const int max_e = 100, dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
char field[max_e][max_e];
int w, h, data[max_e][max_e];
void dfs(int y, int x, int res){
	for(int i = 0; i < 4; i++){
		if(x+dx[i] >= 0 && y+dy[i] >= 0 && x+dx[i] < w && y+dy[i] < h
		 && field[y][x] == field[y+dy[i]][x+dx[i]] && data[y+dy[i]][x+dx[i]] == 0){
		 	data[y+dy[i]][x+dx[i]] = res;
			dfs(y+dy[i], x+dx[i], res);
		}
	}
	return;
}
int main(){
	while(true){
		int res = 0;
		scanf("%d%d", &h, &w);
		if(h == 0 && w == 0) return 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				data[j][i] = 0;
			}
		}
		for(int i = 0; i < h; i++){
			scanf("%s", field[i]);
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(data[i][j] == 0){
					data[i][j] = ++res;
					dfs(i, j, res);
				}
			}
		}
		printf("%d\n", res);
	}
}