#include<iostream>
using namespace std;

int h,w;
char map[100][100];

void prop(int y,int x,char s){

  map[y][x] = 'x';
  if(y+1<h && map[y+1][x] == s)prop(y+1,x,s);
  if(x+1<w && map[y][x+1] == s)prop(y,x+1,s);
  if(y-1>=0 && map[y-1][x] == s)prop(y-1,x,s);
  if(x-1>=0 && map[y][x-1] == s)prop(y,x-1,s);

}

int main(){
  int i,j;
  int ans;
  char tmp;

  while(1){
    cin >> h >> w;
    if(!h && !w)break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	scanf(" %c ",&map[i][j]);
      }
    }

    ans = 0;

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	tmp = map[i][j];
	if(tmp!='x'){
	  prop(i,j,tmp);
	  ans++;
	}
      }
    }

    cout << ans << endl;
  }
}