#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
int H,W;
char grid[101][101] = {};

void dfs(int y,int x,char c){
	grid[y][x] = 'C';
	REP(i,4){
		int ny = y + dy[i];
		int nx = x + dx[i];

		if ((nx >= W) or (W < 0) or (ny >= H) or (H < 0)) continue;
		if (grid[ny][nx] == c) dfs(ny,nx,c);
	}

	return;
}

int main(){
	while(true){
		SCD2(H,W);
		int count = 0;
		getchar();

		if ((H==0) and (W==0)) break;

		REP(i,H){
			REP(j,W){
				cin >> grid[i][j];
			}
			getchar();
		}

		REP(i,H){
			REP(j,W){
				if (grid[i][j] == 'C') continue;
				dfs(i,j,grid[i][j]);
				count++;
			}
		}

		PRINTD(count);
	}
}
