#include <iostream>
using namespace std;

char F[102][102];

void DFS(int Y, int X ,char c){
      if(F[Y][X]!=c)
            return;

      F[Y][X] = '.';

      DFS(Y+1, X  , c);
      DFS(Y  , X+1, c);
      DFS(Y-1, X  , c);
      DFS(Y  , X-1, c);
}

int main(){
      int H,W, cnt;
      char c;
      while(true){
            cin >> H >> W;
                  if(H==0)    break;
            for(int y=1; y<=H; y++)
                  for(int x=1; x<=W; x++)
                  cin >> F[y][x];

            cnt = 0;
            for(int y=1; y<=H; y++)
                  for(int x=1; x<=W; x++)
                  if(F[y][x]=='@' || F[y][x]=='#' || F[y][x]=='*'){
                        cnt++;
                        DFS(y, x, F[y][x]);
                  }
            cout << cnt << endl;
      }
   return 0;
}

