#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<string>
#include<cstring>
#include<math.h>
#include<algorithm>
#include<map>

#include<sstream>
#include<ctype.h>

#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
 
typedef long long ll;
using namespace std;
 
const int INF = 0x7f7f7f7f;
const double PI = acos(-1.0);
const int maxn = 1005;
const int MOD = (int)1e9+7;
#define LOCAL 0
#define MOD 1000000007



bool vis[105][105];
char maps[105][105];

int dx[] = {0,1,-1,0};
int dy[] = {1,0,0,-1};
int n,m;
bool ok(int x,int y){
	if(x < 0 || x >= n || y < 0 || y >= m) return false;
	if(vis[x][y])	return false;
	return true;
}

void dfs(int x,int y,char c){
	for(int i = 0 ; i < 4 ; i ++){
		int newx = x+dx[i];
		int newy = y+dy[i];
		if(ok(newx,newy) && maps[newx][newy] == c){
			vis[newx][newy] = true;
			dfs(newx,newy,c);
		} 
	} 
}

int main(){
 	while(scanf("%d%d",&n,&m) != EOF && (n||m)){
 		for(int i = 0 ; i < n ; i ++) scanf("%s",maps[i]);
 		int cnt = 0;
 		for(int i = 0 ; i < n ; i ++){
		 	for(int j = 0 ; j < m ; j ++){
	 			if(!vis[i][j]){
			 		cnt++;
			 		vis[i][j] = true;
			 		dfs(i,j,maps[i][j]);
			 	}
	 		}
		 }
 		printf("%d\n",cnt);	
	}
} 