#include<iostream>

int W, H;
char field[101][101];

int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };

int ans;

void dfs( int x, int y, char c )
{
	field[x][y] = ' ';

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

		if( 0 <= nx && nx < W && 0 <= ny && ny < H && field[nx][ny] == c )
			dfs( nx, ny, c );
	}
}

int main()
{
	while( std::cin >> H >> W, H | W )
	{
		for( int i = 0; i < H; i++ )
			for( int j = 0; j < W; j++ )
				std::cin >> field[j][i];

		ans = 0;

		for( int i = 0; i < W; i++ )
		{
			for( int j = 0; j < H; j++ )
			{
				if( field[i][j] != ' ' )
				{
					dfs( i, j, field[i][j] );
					ans++;
				}
			}
		}

		std::cout << ans << std::endl;
	}

	return 0;
}