#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;

const int maxn=110;
char mp[maxn][maxn];
bool vis[maxn][maxn];
int to[4][2]={{1,0},{-1,0},{0,-1},{0,1}};
int h,w;

bool bfs(int x,int y,char c)
{
    if (vis[x][y]) return false;
    queue<pair<int,int> > que;
    que.push(make_pair(x,y));
    vis[x][y]=1;
    while (!que.empty())
    {
        pair<int,int> t=que.front(); que.pop();
        for (int i=0;i<4;i++)
        {
            int xx=t.first+to[i][0];
            int yy=t.second+to[i][1];
            if (xx<0||xx>=h||yy<0||yy>=w||mp[xx][yy]!=c||vis[xx][yy])
                continue;
            vis[xx][yy]=1;
            que.push(make_pair(xx,yy));
        }
    }
    return true;
}


int main()
{
    while (cin>>h>>w&&(w||h))
    {
        for (int i=0;i<h;i++)
            for (int j=0;j<w;j++)
                cin>>mp[i][j];

        memset(vis,0,sizeof(vis));
        int ans=0;
        for (int i=0;i<h;i++)
            for (int j=0;j<w;j++)
                if (bfs(i,j,mp[i][j]))
                    ans++;

        printf("%d\n",ans);
    }
    return 0;
}

