#include<iostream>

int w, h;
char farm[102][102];
int dx[] = { 0, 1, 0, -1 }, dy[] = { -1, 0, 1, 0 };
int ans;

void dfs( int x, int y )
{
	char c = farm[x][y];
	farm[x][y] = '.';
	
	for( int i = 0; i < 4; i++ ){
		int ix = x + dx[i];
		int iy = y + dy[i];
		
		if( ix >= 1 && ix <= w && iy >= 1 && iy <= h && farm[ix][iy] == c ){
		 	dfs( ix, iy );
		}
	}
	
 	return;
}

int main()
{
	while( std::cin >> h >> w, h | w ){
		for( int i = 1; i <= h; i++ ){
			for( int j = 1; j <= w; j++ ){
				std::cin >> farm[j][i];
			}
		}
		
		for( int i = 1; i <= h; i++ ){
			for( int j = 1; j <= w; j++ ){
				if( farm[j][i] == '@' || farm[j][i] == '#' || farm[j][i] == '*' ){
				 	dfs( j, i );
					ans++;
				}
			}
		}
		
		std::cout << ans << std::endl;
		ans = 0;
	}

 	return 0;
}