#include <iostream>
#include <cstdio>
using namespace std;
const int MAX_W = 100;
const int MAX_H = 100;

int w,  h, dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1};
char field[MAX_H][MAX_W];

void dfs(int x, int y)
{
    char tmp = field[x][y];
    field[x][y] = '.';
    for(int i = 0; i < 4; i++)
    {
        int nx = x +dx[i];
        int ny = y +dy[i];
        if(nx>=0 && nx < h && ny >=0 && ny < w && field[nx][ny] == tmp)
            dfs(nx, ny);
    }
}

void solve()
{
    int res = 0;
    for(int i = 0; i < h; i++)
        for(int j = 0; j <w; j++)
            if(field[i][j] != '.')
            {
                dfs(i, j);
                res++;
            }
    printf("%d\n",res);
}
int main()
{
    while(scanf("%d%d",&h, &w) == 2 && w && h)
    {
        for(int i = 0; i < h; i++)
            scanf("%s", field[i]);
        solve();
    }
    return 0;
}