#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<climits>
#include<algorithm>
#include<functional>
#include<iomanip>
#define LL long long
using namespace std;

int n,m,cnt,book[110][110],dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
char a[110][110];

bool judge(int x,int y,char c){
    if(x>=0 && x<n && y>=0 && y<m && !book[x][y] && a[x][y]==c){
        return true;
    }
    return false;
}

void dfs(int x,int y){
    book[x][y]=1;
    int i;
    for(i=0;i<4;i++){
        int dx=x+dir[i][0];
        int dy=y+dir[i][1];
        if(judge(dx,dy,a[x][y])) dfs(dx,dy);
    }
}

int main(void){
    while(scanf("%d %d",&n,&m)!=EOF && (n || m)){
        int i,j;
        for(i=0;i<n;i++){
            scanf("%s",a[i]);
        }
        memset(book,0,sizeof(book));
        cnt=0;
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
                if(!book[i][j]){
                    cnt++;
                    dfs(i,j);
                }
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}


