#include <cstdio>

using namespace std;

const int MAX_N = 105;
const int dy[4] = {0, 1, 0, -1};  // j
const int dx[4] = {-1, 0, 1, 0};  // i

int H, W;
char M[MAX_N][MAX_N];

void dfs(int x, int y, char c) {
  M[x][y] = '.';
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (0 <= nx && nx < H && 0 <= ny && ny < W && M[nx][ny] == c) {
      dfs(nx, ny, c);
    }
  }
  return;
}
int main() {
  for (;;) {
    scanf("%d %d", &H, &W);
    if (H == 0) break;
    for (int i = 0; i < H; i++) {
      char c;
      for (int j = 0; j < W; j++) {
        do {
          c = getchar();
        } while (c != '#' && c != '*' && c != '@');
        M[i][j] = c;
      }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (M[i][j] != '.') {
          ans++;
          dfs(i, j, M[i][j]);
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
