#include <iostream>
#include <memory.h>

using namespace std;

char map[105][105];

int h, w;
int ans;
bool used[105][105];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

void dfs(int x, int y, char c)
{
    used[y][x] = true;
    for(int i = 0; i < 4; ++i)
    {
        int tx = x + dx[i];
        int ty = y + dy[i];
        if(tx >= 0 and tx < w and ty >= 0 and ty < h and !used[ty][tx] and map[ty][tx] == c)
            dfs(tx, ty, c);
    }
}

int main()
{
    while(cin>>h>>w and h and w)
    {
        ans = 0;
        memset(used, 0, sizeof(used));
        for(int i = 0; i < h; ++i)
            for(int j = 0; j < w; ++j)
                cin>>map[i][j];

        for(int i = 0; i < h; ++i)
            for(int j = 0; j < w; ++j)
            {
                if(!used[i][j])
                {
                    dfs(j, i, map[i][j]);
                    ans++;
                }
            }

        cout<<ans<<endl;
    }
}
