#include<cstdio>
#include<cstring>
using namespace std;
int h,w,dir[4][2] = {{1,0},{-1,0},{0,-1},{0,1}};
char mmap[105][105];
bool vis[105][105];
void dfs(int x,int y,char c)
{
    vis[x][y] = 1;
    for(int i = 0;i < 4;i++)
    {
        int dx = x + dir[i][0];
        int dy = y + dir[i][1];
        if(dx >=0 &&dx < h&&dy >= 0&&dy < w&&!vis[dx][dy]&&mmap[dx][dy] == c)
            dfs(dx,dy,c);
    }
    return ;
}
int main()
{
    while(scanf("%d %d",&h,&w) != EOF)
    {
        if(h == 0||w == 0)
            break;
        memset(vis,0,sizeof(vis));
        int ans = 0;
        for(int i = 0;i < h;i++)
        {
            getchar();
            for(int j = 0;j < w;j++)
                scanf("%c",&mmap[i][j]);
        }
        for(int i = 0;i < h;i++)
        {
            for(int j = 0;j < w;j++)
            {
                if(!vis[i][j])
                {
                    ans++;
                    dfs(i,j,mmap[i][j]);
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}
