#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 105
using namespace std;
typedef long long ll;
int h,w,ans;
char s[maxn][maxn];
bool vis[maxn][maxn];
const int dx[] = {0,-1,0,1};
const int dy[] = {-1,0,1,0};
void dfs(int x,int y){
	vis[x][y] = true;
	for(int i=0;i<4;i++){
		int cx = x + dx[i];
		int cy = y + dy[i];
		if(cx >= 1 && cx <= h && cy >= 1 && cy <= w && !vis[cx][cy] && s[cx][cy] == s[x][y]) dfs(cx,cy);
	}
}
int main(){
	while(~scanf("%d%d",&h,&w) && h){
		for(int i=1;i<=h;i++) scanf("%s",s[i] + 1);
		memset(vis,0,sizeof(vis));
		ans = 0;
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if(!vis[i][j]){
					ans++;
					dfs(i,j);
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

