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


int h, w;
bool done[100][100];
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};
string field[100];

void dfs(int y, int x) {
	if(done[y][x])
		return;

	done[y][x] = true;

	for(int i = 0; i < 4; ++i) {
		int nx = x + dx[i];
		int ny = y + dy[i];

		if(nx < 0 || ny < 0 || nx >= w || ny >= h)
			continue;

		if(field[y][x] == field[ny][nx])
			dfs(ny, nx);
	}
}


int main() {
	cin.tie(false);
	ios::sync_with_stdio(false);

	for(; cin >> h >> w, h | w;) {
		for(int i = 0; i < h; ++i)
			cin >> field[i];

		memset(done, false, sizeof(done));
		int ans = 0;
		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				if(!done[i][j]) {
					++ans;
					dfs(i, j);
				}
			}
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}