#include<iostream>

using namespace std;

const int MAX = 101;

char data[MAX][MAX];
int w,h;


void solve(int i, int j, char c){
  data[i][j] = '0';
  if(i+1 < w && data[i+1][j] == c) solve(i+1,j,c);
  if(j+1 < h && data[i][j+1] == c) solve(i,j+1,c);
  if(i-1 >=0 && data[i-1][j] == c) solve(i-1,j,c);
  if(j-1 >=0 && data[i][j-1] == c) solve(i,j-1,c);

}

int main(){
  while(cin >> w >> h && w+h){
    for(int i = 0; i < w; i++)
      for(int j = 0; j < h; j++)
	cin >> data[i][j];
    int sum = 0;
    for(int i = 0; i < w; i++)
      for(int j = 0; j < h; j++)
	if(data[i][j] != '0'){
	  solve(i,j,data[i][j]);
	  sum++;
	}
    cout << sum << endl;
  }
  return 0;
}