#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

char ba[100][100];
int h,w;

int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

void go(int x, int y, char c) {
  ba[x][y] = '.';
  REP(k,4) {
    int xx = x+dx[k];
    int yy = y+dy[k];
    if (xx<0||xx>=w||yy<0||yy>=h) continue;
    if (ba[xx][yy]==c) {
      go(xx,yy,c);
    }
  }
}

int main() {
  while(cin>>h>>w,h+w) {
    REP(y,h)
      REP(x,w)
      cin>>ba[x][y];

    int ans = 0;
    REP(y,h) {
      REP(x,w) {
        if (ba[x][y] != '.') {
          go(x,y,ba[x][y]);
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
}