#include <iostream>
#include <string>
using namespace std;
int w, h;
string field[101];

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

void dfs(char c, int x, int y) {
	if (x < 0 || w <= x || y < 0 || h <= y) return;
	if (c != field[y][x]) return;
	field[y][x] = 'x';
	for (int i = 0; i < 4; i++) {
		dfs(c, x + dx[i], y + dy[i]);
	}
}

int main() {
	while (cin >> h >> w, w || h) {
		for (int i = 0; i < h; i++) {
			cin >> field[i];
		}
		int count = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (field[i][j] != 'x') {
					dfs(field[i][j], j, i);
					count++;
				}
			}
		}
		cout << count << endl;
	}
}