//#include <bits/stdc++.h>

#include <cstdio>

using namespace std;

const int MAX_W = 103, MAX_H = 103;

int W, H;
char G[MAX_H][MAX_W];
int res;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

void dfs(int x,int y){
    char c = G[x][y];
    G[x][y] = '!'; //一定要把dfs过的点标成不能再访问,否则会回来

    for(int i = 0;i < 4;i++){
        int nx = x + dx[i], ny = y + dy[i];
        if(0<=nx && nx<H && 0<=ny && ny<W && G[nx][ny] == c)
            dfs(nx, ny);

    }
}

void solve(){
    res = 0;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(G[i][j] != '!'){
                dfs(i, j);
                res++;
            }
        }
    }
    printf("%d\n", res);
    return;
}

int main(){
    while(~scanf("%d %d",&H, &W)){
        if(W == 0&& H == 0) break;
        for(int i = 0;i < H;i++){
            scanf("%s", G[i]);
        }
        solve();
    }
    return 0;
}
