#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

int H,W;
char field[110][110];
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};

void dfs(int i, int j){// cout << i << ' ' << j << endl;
  int k;
  char e = field[i][j];

  field[i][j] = '.';

  rep(k,4){
    int my = i + dy[k];
    int mx = j + dx[k];
    if(0 <= my && my < H && 0 <= mx && mx < W && field[my][mx] == e) dfs(my,mx);
  }
}

int main(){
  int i,j;

  for(;;){
    scanf("%d %d",&H,&W); if(H == 0 && W == 0) break;
    rep(i,H) scanf("%s",&field[i]);

    int res = 0;
    rep(i,H) rep(j,W){
      if(field[i][j] == '#' || field[i][j] == '*' || field[i][j] == '@'){
        dfs(i,j);
        res++;
      }
    }

    printf("%d\n",res);
  }

  return 0;
}