#include <iostream>
#include <stack>
#include <string>

using namespace std;

const int MAXN = 100;

struct Tree{
    int x;
    int y;
    char type;
    Tree(int x_=-1, int y_=-1, char type_='@'){
        x = x_;
        y = y_;
        type = type_;
    }
};

bool visit[MAXN][MAXN];
char tree_map[MAXN][MAXN];
int H, W;
int ans;
int dir[4][2] = {{1,0}, {-1,0}, {0,1}, {0,-1}};
stack<Tree> s;

void initialize(){
    ans = 0;
    while(!s.empty()){
        s.pop();
    }
}

bool DFS(int x, int y){
    if(visit[x][y])
        return false;
    s.push(Tree(x, y, tree_map[x][y]));
    visit[x][y] = true;
    while(!s.empty()){
        Tree cuur = s.top();
        s.pop();
        for(int i=0; i<4; ++i){
            int x_new = cuur.x + dir[i][0];
            int y_new = cuur.y + dir[i][1];
            if(x_new<0 || x_new>=H || y_new<0 || y_new>=W || visit[x_new][y_new])
                continue;
            if(tree_map[x_new][y_new] != cuur.type)
                continue;
            visit[x_new][y_new] = true;
            s.push(Tree(x_new, y_new, cuur.type));
        }
    }
    return true;
}

int solve(){
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            if(DFS(i, j))
                ++ans;
        }
    }
    return ans;
}

int main(){
    while(cin>>H>>W, H||W){
        for(int i=0; i<H; ++i){
            string str;
            cin >> str;
            for(int j=0; j<W; ++j){
                tree_map[i][j] = str[j];
                visit[i][j] = false;
            }
        }
        initialize();
        cout << solve() << endl;
    }
    return 0;
}


