#include <iostream>

using namespace std;

const int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
char table[100][100];

void Dfs(int h, int w, int x, int y, char cur) {
  table[x][y] = 'X';
  for (int i = 0; i < 4; ++i) {
    int next_x = x + dir[i][0];
    int next_y = y + dir[i][1];
    if (next_x >= 0 && next_x < w
        && next_y >=0 && next_y < h
        && table[next_x][next_y] == cur) {
        Dfs(h, w, next_x, next_y, cur);
    }
  }
}

int main() {
  int h, w;
  while (cin >> h >> w, w > 0) {
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> table[i][j];
      }
    }
    int ret = 0;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (table[i][j] != 'X') {
          Dfs(h, w, i, j, table[i][j]);
          ++ret;
        }
      }
    }
    cout << ret << endl;
  }
  return 0;
}