#include <iostream>
#include <cstring>

using namespace std;

const int MAXH = 105;
const int MAXW = 105;
char tiles[MAXH][MAXW];
int dir[4][2] = {{0,-1},{0,1},{-1,0},{1,0}};
int vis[MAXH][MAXW];
int cnt;
int w,h;

void dfs(int x,int y)
{
    for(int i=0;i<4;++i){
        int xx = x + dir[i][0];
        int yy = y + dir[i][1];
        if(xx<0||xx>=h||yy<0||yy>=w)
            continue;
        if(tiles[xx][yy]==tiles[x][y]&&!vis[xx][yy]){
            vis[xx][yy] = 1;
            dfs(xx,yy);
        }
    }
}

int main()
{
    int sx,sy;
    while(cin>>h>>w){
        if(w==0||h==0) break;
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                cin>>tiles[i][j];
            }
        }
        memset(vis,0,sizeof(vis));
        cnt = 0;
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                if(!vis[i][j]){
                    vis[i][j]=1;
                    dfs(i,j);
                    ++cnt;
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

