#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

long H,W;

void saiki(char map[][100],long i,long j,char c){

    if(map[i][j] != ' '){
	map[i][j] = ' ';
	for (long dx=-1;dx<=1;dx++){
	    if(j+dx >= 0 && j+dx<W){
		if(map[i][j+dx] == c){
		    saiki(map,i,j+dx,c);
		}
	    }
	}
	for (long dy=-1;dy<=1;dy++){
	    if(i+dy >= 0 && i+dy<H){
		if(map[i+dy][j] == c){
		    saiki(map,i+dy,j,c);
		}
	    }
	}
    }
}


int main(){

    char map[100][100];
    while(true){
	long count = 0;
	cin >> H >> W;
	if(H==0&&W==0) break;
	for(long i=0;i<W;i++){
	    for(long j=0;j<H;j++){
		cin >> map[i][j];
	    }
	}

	char c;
	for(long i=0;i<H;i++){
	    for(long j=0;j<W;j++){
		c = map[i][j];
		if(c != ' '){
		    count++;
		    saiki(map,i,j,c);
		}
	    }
	}

	cout << count << endl;
	for(long i=0;i<100;i++){
	    for(long j=0;j<100;j++){
		map[i][j] = 0;
	    }
	}
    }
	return 0;
    }