#include <iostream>
using namespace std;

int h, w;
char map[100][100];
int ans;

bool safe(int x, int y){
    return (0 <= x && 0 <= y && x < h && y < w);
}

void solve(char c, int x, int y){
    map[x][y] = '?';
    if (map[x+1][y] == c && safe(x+1, y)) solve(c, x+1, y);
    if (map[x-1][y] == c && safe(x-1, y)) solve(c, x-1, y);
    if (map[x][y+1] == c && safe(x, y+1)) solve(c, x, y+1);
    if (map[x][y-1] == c && safe(x, y-1)) solve(c, x, y-1);
    return;
}

int main(){
    while (1){
	cin >> h >> w;
	if (h == 0 && w == 0) break;

	ans = 0;
	for (int i = 0; i < h; i++){
	    for (int j = 0; j < w; j++){
		cin >> map[i][j];
	    }
	}
	
	for (int i = 0; i < h; i++){
	    for (int j = 0; j < w; j++){
		if (map[i][j] != '?'){
		    ans++;
		    solve(map[i][j], i, j);
		}
	    }
	}

	cout << ans << endl;
    }
}