#include <iostream>
#include <algorithm>
using namespace std;

const int MAXH = 100;
const int MAXW = 100;
int H, W;
char G[MAXH][MAXW];

void dfs(int i, int j) {
  const static int di[] = {0,1,0,-1};
  const static int dj[] = {1,0,-1,0};
  char c = G[i][j];
  G[i][j] = ' ';
  for(int k = 0; k < 4; ++k) {
    int ni = i + di[k];
    int nj = j + dj[k];
    if(ni < 0 || ni >= H) continue;
    if(nj < 0 || nj >= W) continue;
    if(G[ni][nj] != c) continue;
    dfs(ni, nj);
  }
}

int main() {
  while(cin >> H >> W && (H|W)) {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> G[i][j];
      }
    }
    int res = 0;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        if(G[i][j] != ' ') {
          ++res;
          dfs(i, j);
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}