#include <cstdio>

#define MAX_N 100

int W, H, n=0;
char field[MAX_N][MAX_N];

void dfs(int x, int y, char ch){
  field[x][y] = '.';

  for (int dx = -1; dx < 2; dx++) {
    int nx = x + dx, ny = y;
    if(0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] == ch){
      dfs(nx,ny,ch);
    }
  }

  for (int dy = -1; dy < 2; dy++) {
    int nx = x, ny = y + dy;
    if(0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] == ch){
      dfs(nx,ny,ch);
    }
  }
  return;
}

int main(int argc, char const *argv[]) {

while(1){
scanf("%d",&W );
scanf("%d",&H );
n = 0;
if(W == 0 && H == 0) break;

for (int i = 0; i < H; i++) {
  for (int j = 0; j < W; j++) {
    scanf(" %c",&field[i][j] );
  }
}

for (int i = 0; i < H; i++) {
  for (int j = 0; j < W; j++) {
    if(field[i][j] != '.'){
      dfs(i,j,field[i][j]);
      n++;
    }
  }
}
printf("%d\n",n );
}
  return 0;
}