// AOJ 0118
#include<cstdio>
#define rep( i, a ) for( int i = 0; i != (a); ++i )

int H, W;
char fld[100][100];
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };

void dfs( char ch, int x, int y )
{
	fld[y][x] = ' ';

	rep( i, 4 )
	{
		int nx = x + dx[i], ny = y + dy[i];

		if( nx >= 0 && nx < W && ny >= 0 && ny < H && fld[ny][nx] == ch )
			dfs( ch, nx, ny );
	}

	return;
}

int main()
{
	while( scanf( "%d%d", &H, &W ), H | W )
	{
		rep( i, H )
		{
			getchar();
			rep( j, W )
				fld[i][j] = getchar();
		}

		int ans = 0;
		rep( i, H )
			rep( j, W )
				if( fld[i][j] != ' ' )
					dfs( fld[i][j], j, i ), ++ans;

		printf( "%d\n", ans );
	}

	return 0;
}