#include <cstdio>

int H,W;
int res = 0;
char field[105][105];
int sh_x[4] = {0, 0, -1, 1};
int sh_y[4] = {1, -1, 0, 0};

void solve(char target, int x, int y) {
  field[y][x] = '!';
  for (int i=0;i<4;i++) {
    int new_x = x + sh_x[i];
    int new_y = y + sh_y[i];
    if (new_x >= 0 && new_x < W && new_y >=0 && new_y < H && field[new_y][new_x] == target)
      solve(target, new_x, new_y);
  }
}

int main() {
  while (1)
  {
    scanf("%d %d", &H, &W);
    getchar();
    if (!W && !H) {
      break;
    }

    int i,j;
    for (i=0;i < H; i++) {
      fgets(field[i], 105, stdin);
      field[i][W] = '!';
    }

    for (i=0;i<W;i++) {
      field[H][i] = '!';
    }

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

  return 0;
}


