#include<stdio.h>

const int N = 100+2;
char a[N][N];
int w,h;
const char INVALID_CHAR = '_';

void destroj(int i,int j, char c)
{
	if(i<0 || j<0 || i>=h || j>= w)
		return;
	if(a[i][j] != c)
		return;
	a[i][j] = INVALID_CHAR;

	const int di[] = {-1,1,0,0};
	const int dj[] = {0,0,1,-1};
	for(int index = 0; index < 4; ++index)
		destroj(i+di[index],j+dj[index],c);
}

int main(void)
{
	int i,j;
	while(scanf("%d%d", &h,&w),h)
	{
		for(i = 0; i < h; ++i)
			scanf("%s",a[i]);
		int v = 0;
		for(i = 0; i < h; ++i)
			for(j = 0; j < w; ++j)
			{
				if(a[i][j] != INVALID_CHAR)
				{
					destroj(i,j,a[i][j]);
					++v;
				}
			}
		printf("%d\n",v);
	}
	return 0;
}