#include <iostream>
using namespace std;

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

void dfs(int x, int y, char ch){
	c[y][x] = 0;
	for(int i = 0 ; i < 4 ; i++ ){
		int mx = x + dx[i], my = y + dy[i];
		if( mx < 0 || my < 0 || W <= mx || H <= my ) continue;
		if( c[my][mx] == ch){
			dfs(mx, my, ch);
		}
	}
}

int main(){
	while( cin >> H >> W , W || H ){
		for(int y = 0 ; y < H ; y++ ) cin >> c[y];
		int ans = 0;
		for(int y = 0 ; y < H ; y++ ){
			for(int x = 0 ; x < W ; x++ ){
				if( c[y][x] != 0 ){
					ans++;
					dfs(x, y, c[y][x]);
				}
			}
		}
		cout << ans << endl;
	}
}