/*
P135
AOJ 0118 Property Distribution
*/

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <functional>
#include <string.h>
using namespace std;

int W, H;
char board[110][110];

bool read()
{
    scanf("%d%d", &H, &W);
    if(W==0 && H==0) return false;
    for(int i=0; i<H; ++i)
        scanf("%s", board[i]);
    return true;
}

bool isVisited[110][110];
int step;

void dfs(int x, int y, char c){
    if(x<0 || x>=H || y<0 || y>=W) return;
    if(board[x][y]!=c) return;
    if(isVisited[x][y]) return;
    isVisited[x][y] = true;
    dfs(x+1, y, c);
    dfs(x-1, y, c);
    dfs(x, y+1, c);
    dfs(x, y-1, c);
}

void solve()
{
    int ans = 0;
    memset(isVisited, 0, sizeof(isVisited));
    for(int i=0; i<H; ++i)
    for(int j=0; j<W; ++j)
    {
        if(!isVisited[i][j]){
            ans++;
            dfs(i, j, board[i][j]);
        }
    }

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


int main()
{
    while(read())
        solve();
}