#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
 
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(x,b) (0<=(x)&&(x)<(b))
using namespace std;
 
int H, W;
int board[128][128];
char point;
 
void dfs(int y, int x){
  board[y][x] = '.';
  int dy[] = {0,-1,0,1}, dx[] = {-1,0,1,0};
  rep(i, 4){
    int ny = y + dy[i], nx = x + dx[i];
    if(BW(ny,H) && BW(nx, W) && board[ny][nx] == point)
      dfs(ny, nx);
  }
  return;
}
 
int main(){
  char in[128];
  while(scanf("%d%d", &H, &W) && H+W){
    rep(i, H){
      scanf("%s", in);
      rep(j, W) 
    board[i][j] = in[j];
    }
     
    int res = 0;
    rep(i, H) rep(j, W){
      if(board[i][j] != '.'){
    point = board[i][j];
    dfs(i, j);
    res++;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
