#include <iostream>
using namespace std;

#define MAX_W 100
#define MAX_H 100

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

void dfs(int x, int y, char z)
{
 
    for (int i=0; i<4; i++)
    {
        int xx = x + dx[i], yy = y + dy[i];
        if(xx>=0 && xx<h && yy>=0 && yy<w && maze[xx][yy]==z)
        {
            maze[xx][yy] = '1';
            dfs(xx, yy, z);
        }
    }
}


int main()
{
    while(scanf("%d %d", &h, &w), h+w)
    {
        int i, j;
        char z;
        ans = 0;
        
        for (i=0; i<h; i++)
            scanf("%s", maze[i]);
        
        
        for (i=0; i<h; i++)
            for(j=0; j<w; j++)
                if(maze[i][j]=='@' || maze[i][j]=='#' || maze[i][j]=='*')
                {
                    ans ++;
                    z = maze[i][j];
                    maze[i][j] = 1;
                    dfs(i, j, z);
                }
        
        printf("%d\n", ans);
    }
    return 0;
}