#include<iostream>
using namespace std;

char F[102][102];

bool isEnabled(int y, int x){
    char c = F[y][x];
    return (c == '@' || c == '#' || c == '*');
}              

void DFS(int y, int x, char c) {
    if(F[y][x] != c) return;

    F[y][x] = '.';

    DFS(y - 1, x, c);
    DFS(y + 1, x, c);
    DFS(y, x -1, c);
    DFS(y, x + 1, c);
}

void print(int h, int w){
    for(int y = 1;y <= h;y++){
        for(int x = 1;x <= w;x++){
            cout << F[y][x];
        }
        cout << endl;
    }
    cout << endl;
}

int main(){
    while(true) {
        int H, W;
        cin >> H >> W;
        if(!H && !W) break;
        for(int y = 1;y <= H;y++) {
            for(int x = 1;x <= W;x++){
                cin >> F[y][x];
            }
        }

        int ans = 0;
        for(int y = 1;y <= H;y++){
            for(int x = 1;x <= W;x++){
                if(isEnabled(y, x)){
                    ans++;
                    DFS(y, x, F[y][x]);
                }
            }
        }

        cout << ans << endl;
    }
    return 0;
}