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

using namespace std;

bool used[101][101];

vector<string> field;
int W,H;

void solve(int x,int y,char ch){
  //  cout << x << " " << y << endl;
  if(used[y][x])
    return;
  else if(field[y][x] == ch){
    used[y][x] = true;
    for(int i = -1; i <= 1; i++){
      for(int j = -1; j <= 1; j++){
	if(x + i >= 0 && x + i < W && y + j >= 0 && y + j < H){
	  solve(x+i,y+j,ch);
	}
      }
    }
  }
  else
    return;
}

int main(){
  
  while(1){
    field.clear();
    for(int i = 0; i < 101; i++)
      fill(used[i],used[i]+101,false);
    
    cin >> H >> W;
    if(W == 0 || H == 0)
      break;
    string str;
    for(int i = 0; i < H; i++){
      cin >> str;
      field.push_back(str);
    }
    int cnt = 0;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
	if(used[i][j])
	  continue;
	cnt++;
	//	cout << "cnt" << endl;
	solve(j,i,field[i][j]);
      }
    }
    cout << cnt << endl;
  }
  
  return 0;
}