#include <iostream>

using namespace std;

const int W_MAX = 100;
const int H_MAX = 100;

int W, H;
char tile[H_MAX+2][W_MAX+2];

int ans;

void init() {
  for (int i = 0; i < H_MAX+2; i++) {
    for (int j = 0; j < W_MAX+2; j++) {
      tile[i][j] = 0;
    }
  }
  ans = 0;
}

void dfs(int n, int m) {
  char fruit = tile[n][m];
  tile[n][m] = 0;
  for (int i = -1; i < 2; i++) {
    for (int j = -1; j < 2; j++) {
      if (i * j == 0 && tile[n+i][m+j] == fruit) {
        dfs(n+i, m+j);
      }
    }
  }
}
      
void solve() {
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (tile[i+1][j+1] != 0) {
        dfs(i+1, j+1);
        ans++;
      }
    }
  }
  cout << ans << endl;
}

int main() {

  while (true) {
    cin >> W >> H;
    if (W == 0 && H == 0) break;
    init();
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cin >> tile[i+1][j+1];
      }
    }
    solve();
  }

  return 0;
}