#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int H,W;//縦、横
char board[100][100];
int ans;
char c;
void dfs(int x,int y,char c){
  board[x][y] ='.';
  for(int i = 0;i <4;i++){
    int nx = x +dx[i];
    int ny = y +dy[i];
    if(nx >=0&&nx <H &&ny >=0 &&ny <W){
      if(board[nx][ny] ==c){
	dfs(nx,ny,c);
      }
  }
  }
}
int main()
{
  while(cin >>H>>W,H){
    ans = 0;
    for(int i = 0;i <H;i++){
      for(int j = 0; j < W;j++){
	cin >>board[i][j];
	  }
    }
    for(int i = 0;i < H;i++){
      for(int j = 0;j <W;j++){
	if(board[i][j] =='@'||board[i][j] =='#'||board[i][j] =='*'){
	  ans++;
	  c = board[i][j];
	  dfs(i,j,c);
      }
    }
    }
    cout <<ans<<endl;
  }
  return 0;
}