#include <iostream>

#define MAX_H 100
#define MAX_W 100

int H, W;
char field[MAX_H][MAX_W];

void dfs(int h, int w, char fruit) {
    field[h][w] = 'x';
    if (0<=w+1 && w+1<W && 0<=h && h<H && field[h][w+1] == fruit) dfs(h, w+1, fruit);
    if (0<=w-1 && w-1<W && 0<=h && h<H && field[h][w-1] == fruit) dfs(h, w-1, fruit);
    if (0<=w && w<W && 0<=h+1 && h+1<H && field[h+1][w] == fruit) dfs(h+1, w, fruit);
    if (0<=w && w<W && 0<=h-1 && h-1<H && field[h-1][w] == fruit) dfs(h-1, w, fruit);
}

void solve() {
    int res=0;
    for (int h=0; h<H; h++) {
        for (int w=0; w<W; w++) {
            if (field[h][w] != 'x') {
                dfs(h, w, field[h][w]);
                res++;
            }
        }
    }
    std::cout << res << std::endl;
}

int main() {
    while (true) {
        std::cin >> H >> W;
        if (!H && !W) break;

        for (int h=0; h<H; h++) {
            for (int w=0; w<W; w++) {
                std::cin >> field[h][w];
            }
        }
        solve();
    }

    return 0;
}

