#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std;

int W, H;
string m[120];
bool visit[120][120];
const int di[4] = {0,0,-1,1};
const int dj[4] = {1,-1,0,0};

void dfs(const int ci, const int cj, const char cc) {
  for (int i = 0; i < 4; ++i) {
    int ni = ci + di[i], nj = cj + dj[i];
    if (ni < 0 || nj < 0 || W <= ni || H <= nj) continue;
    if (m[ni][nj] != cc || visit[ni][nj]) continue;
    visit[ni][nj] = true;
    dfs(ni, nj, cc);
  }
}

int solve() {
  memset(visit, 0, sizeof visit);
  int ret = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (!visit[i][j]) {
        dfs(i, j, m[i][j]);
        ++ret;
      }
    }    
  }
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  while (cin >> H >> W, H || W) {
    for (int i = 0; i < H; ++i)
      cin >> m[i];
    cout << solve() << endl;
  }
  return 0;
}