#include <iostream>
#include <string>

using namespace std;

char cmap[100][100];
int h,w;
int vx[] = {0, -1, 1, 0}, vy[] = {-1, 0, 0, 1};

void search(int y, int x, char ch){
	if(y < 0 || h <= y || x < 0 || w <= x || cmap[y][x] != ch) return;
	cmap[y][x] = '\0';
	for (int i = 0; i < 4; i++) {
		search(y + vy[i], x + vx[i], ch);
	}
	return;
}

int main(){
	int c;
	string buf;
	while(cin >> h >> w,h != 0, w != 0){
		c = 0;
		for (int i = 0; i < h; i++) {
			cin >> buf;
			for (int j = 0; j < w; j++) {
				cmap[i][j] = buf[j];
			}
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (cmap[i][j] != '\0') {
					search(i, j, cmap[i][j]);
					++c;				
				}
			}
		}
		cout << c << endl;
	}
	return 0;
}