#include<cstdio>
int W, H;
const int MAXW = 105;
char field[MAXW][MAXW];
int res = 0;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
void dfs(int x, int y)
{
    char tmp = field[x][y];
    field[x][y] = ' ';
    for(int i = 0; i < 4; i++){
        int nx = x + dx[i], ny = y + dy[i];
        if(nx >= 0 && nx < H && ny >= 0 && ny < W && field[nx][ny] == tmp){
            dfs(nx, ny);
        }
    }

}
int main()
{
    while(scanf("%d%d", &H, &W) && H){
        res = 0;
        for(int i = 0; i < H; i++)
            scanf("%s", field[i]);
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(field[i][j] != ' '){
                    dfs(i, j);
                    res++;
                }
            }
        }
        printf("%d\n", res);
    }
}

