//
//  0118.cpp
//  
//
//  Created by Yoshida Satoshi on 2017/11/16.
//
//

#include <iostream>

using namespace std;

#define MAX 100
#define FOR(index,max) for(int index=0;index<max;index++)

void visit(int shurui,int i,int j,int *state,int H,int W){
    if(i<0||i>H-1||j<0||j>W-1) return ;
    if(state[i*W+j]!=shurui) return ;
    state[i*W+j]=0;
    visit(shurui,i+1,j,state,H,W);
    visit(shurui,i-1,j,state,H,W);
    visit(shurui,i,j+1,state,H,W);
    visit(shurui,i,j-1,state,H,W);
    return ;
}

int main(){
    int state[MAX*MAX];
    int H,W;
    char in;
    int ans=0;
    while(1){
        cin>>H>>W;
        if(H==0&&W==0) break;
        FOR(i,H){
            FOR(j,W){
                cin>>in;
                if(in=='@') state[i*W+j]=1;
                if(in=='#') state[i*W+j]=2;
                if(in=='*') state[i*W+j]=3;
            }
        }
        
        FOR(i,H){
            FOR(j,W){
                if(state[i*W+j]!=0){
                    visit(state[i*W+j],i,j,state,H,W);
                    ans++;
                }
            }
        }
        
        cout<<ans<<endl;
    }
    
    return 0;
}