#include<iostream>
using namespace std;

const int dx[4] = {0, -1, 0, 1}, dy[4] = {1, 0, -1, 0};
char field[108][108];
int W, H;

void dfs(int x, int y, char c) {
  if (x < 0 || W <= x || y < 0 || H <= y) return;
  if (field[x][y] != c) return;
  field[x][y] = '.';
  
  int area = 1;
  for (int i = 0; i < 4; i++) {
    dfs(x + dx[i], y + dy[i], c);
  }
  return;
}

int solve() {
  int area = 0;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (field[x][y] == '.') continue;
      area++;
      dfs(x, y, field[x][y]);
    }
  }
  return area;
}

int main() {
  while (cin >> W >> H and W) {
    for (int y = 0; y < 108; y++) {
      for (int x = 0; x < 108; x++) {
        field[x][y] = '.';
      }
    }
    
    for (int y = 0; y < H; y++) {
      string row;
      cin >> row;
      for (int x = 0; x < W; x++) {
        field[x][y] = row[x];
      }
    }

    cout << solve() << endl;
  }
  return 0;
}