#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

//������԰
char field[105][105];
int dx[4] = {-1,0,1,0},dy[4] = {0,-1,0,1};
int res = 0;
int M,N;
void dfs(int x, int y){
    char c = field[x][y];
    field[x][y] = ' ';
    for(int m = 0; m < 4; m++){
        int a = x+dx[m];
        int b = y + dy[m];
        if(a>0&&b>0&&a<=M&&b<=N){
            if(field[a][b] == c) {

                dfs(a,b);
            }
        }
    }
    return ;
}
int main()
{   while(cin>>M>>N){
    if(M==0||N==0) break;
    for(int i = 1;i <=M;i++){
        for(int j = 1;j <= N;j++){
            cin>>field[i][j];
        }
    }
    for(int i = 1;i <= M;i++){
        for(int j = 1;j <= N;j++){
            if(field[i][j] != ' ') {
                dfs(i,j);
                field[i][j] = '0';
                }
            }
        }

    for(int i = 1;i <= M;i++){
        for(int j = 1;j <= N;j++){
            if(field[i][j] == '0') res++;
            //cout<<field[i][j];
        }
        //cout<<endl;
    }
    cout<<res<<endl;
    res = 0;
}
      return 0;
}

