#include <iostream>
#include <stdio.h>

using namespace std;

char mmap[105][105];
int dire[4][2] = {0,1,0,-1,1,0,-1,0};
int x,y;
int count;
char sign;

void dfs(int h,int l){
    mmap[h][l] = '.';

    for(int i = 0; i < 4; i++){
        int xx = h + dire[i][0];
        int yy = l + dire[i][1];

        if(mmap[xx][yy] == sign && xx >= 1 && yy >= 1 && xx <= x && yy <= y){
            dfs(xx,yy);
        }
    }
}

void solve(){
    for(int i = 1; i <= x; i++){
        for(int j = 1; j <= y; j++){
            if(mmap[i][j] != '.'){
                sign = mmap[i][j];
                dfs(i,j);
                count++;
            }
        }
    }

    cout << count << endl; 
}

int main(void){
    while(~scanf("%d %d",&x,&y)){
        if(x == 0 && y == 0){
            break;
        }

        count = 0;

        for(int i = 1; i <= x; i++){
            getchar();
            for(int j = 1; j<= y; j++){
                scanf("%c",&mmap[i][j]);
            }
        }

        solve();
    }
}
