#include<iostream>
using namespace std;

int H, W;
int farm[100][100];
bool used[100][100];
char tmp[100];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

void dfs(int x, int y, int fruit) {
    used[x][y] = true;
    for (int i = 0; i < 4; i++) {
        int x1 = x+dx[i], y1 = y+dy[i];
        if (x1 >= 0 && x1 < H && y1 >= 0 && y1 < W 
            && farm[x1][y1] == fruit && !used[x1][y1]) {
            dfs(x1,y1,fruit);
        }
    }
}

void solve() {
    int res = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (!used[i][j]) {
                dfs(i,j,farm[i][j]);
                res++;
            }
        }
    }
    cout << res << "\n";
}

int main() {
    while (cin>>H>>W && (H||W)) {
        for (int i = 0; i < H; i++) {
            cin >> tmp;
            for (int j = 0; j < W; j++) {
                if (tmp[j] == '@') farm[i][j] = 0;
                else if (tmp[j] == '#') farm[i][j] = 1;
                else if (tmp[j] == '*') farm[i][j] = 2;
                used[i][j] = false;
            }
        }
        solve();
    }
}
