#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <map>
#include <list>

using namespace std;

typedef pair<int, int> P;

#define MAX_H 100
#define MAX_W 100

int H, W;
char farm[ MAX_H ][ MAX_W + 1 ];
const int dx[ 4 ] = { 1, 0, -1, 0 }, dy[ 4 ] = { 0, 1, 0, -1 };

void DFS( int x, int y ) {
	char ch = farm[ y ][ x ];
	farm[ y ][ x ] = '.';
	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 && farm[ ny ][ nx ] == ch ) { DFS( nx, ny ); }
	}
}

int main()
{
	while( scanf( "%d %d", &H, &W ), H || W ) {
		for( int y = 0; y < H; ++y ) { scanf( "%s", farm[ y ] ); }

		int ans = 0;
		for( int y = 0; y < H; ++y ) {
			for( int x = 0; x < W; ++x ) {
				if( farm[ y ][ x ] != '.' ) {
					DFS( x, y );
					++ans;
				}
			}
		}
		printf( "%d\n", ans );
	}
	return 0;
}