#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;


void print_array(int h, int w, bool array[111][111]){
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cout<<array[i][j];
        }cout<<endl;
    }cout<<endl;
}


bool property_distribution(int orchard[111][111], bool cheack_flag[111][111], int now_h, int now_w, int fluit_num){
    if(orchard[now_h][now_w]!=fluit_num)return 0;
    else{
        if(cheack_flag[now_h][now_w]==1)return 1;
        else {
            cheack_flag[now_h][now_w]=1;
            return
            property_distribution(orchard, cheack_flag, now_h+1, now_w, fluit_num)+
            property_distribution(orchard, cheack_flag, now_h-1, now_w, fluit_num)+
            property_distribution(orchard, cheack_flag, now_h, now_w+1, fluit_num)+
            property_distribution(orchard, cheack_flag, now_h, now_w-1, fluit_num);
        }
    }
    
}


int main(){
    //入力作業
    int H,W;
    while(cin>>H>>W){
        if(!H&&!W)break;
        
        int orchard[111][111]={0};
        
        for(int i=1; i<=H; i++){
            for(int j=1; j<=W; j++){
                char input;
                cin>>input;
                if(input=='#'){
                    orchard[i][j]=1;
                }else if(input=='*'){
                    orchard[i][j]=2;
                }else if(input=='@'){
                    orchard[i][j]=3;
                }
            }
        }
        
        
        //入力終了
        //処理開始
        bool cheack_flag[111][111]={0};
        int ans=0;
        for(int i=1; i<=H; i++){
            for(int j=1; j<=W; j++){
                if(cheack_flag[i][j]==0&&orchard[i][j]!=0){
                    property_distribution(orchard, cheack_flag, i, j, orchard[i][j]);
                    ans++;
                    
                    /////
                    //print_array(10, 10, cheack_flag);
                    /////
                }
            }
        }
        cout<<ans<<endl;
    }

}