#include <iostream>
#include <string>
#include <vector>
using namespace std;

int h, w, ans;
vector<vector<int>> mp(100,vector<int>(100,-1));
vector<string> in_str(100);

void re_set(){
    for(int i = 0;i<100;i++){
        in_str[i] = "";
        for(int j = 0;j<100;j++){
            mp[i][j] = -1;
        }
    }
    return;
}

int zentan(int x, int y, int num, char pre_num){
    if(x<0 || y < 0 || x >= h || y >= w || mp[x][y]!=-1 || in_str[x][y] != pre_num) return 0;
    mp[x][y] = num;
    int temp;
    temp = zentan(x+1,y,num,in_str[x][y]);
    temp = zentan(x,y+1,num,in_str[x][y]);
    temp = zentan(x-1,y,num,in_str[x][y]);
    temp = zentan(x,y-1,num,in_str[x][y]);
    return 1;
}

int main(){
    while(cin >> h >> w){
        if(!h && !w) return 0;
        re_set();
        ans = 0;
        for(int i = 0;i<h;i++){
            string tmp;
            cin >> tmp;
            in_str[i] = tmp;
        }
        for(int i = 0;i<h;i++){
            for(int j = 0;j<w;j++){
                ans += zentan(i,j,ans,in_str[i][j]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}
