#include <iostream>
#include <cstdio>

using namespace std;

const int MAX = 100;

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

//INPUT
int H, W, res;
char garden[MAX][MAX];

void dfs(int x, int y, char c) {
	garden[x][y] = '.';
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (garden[nx][ny] == c) dfs(nx, ny, c);
	}
	return ;
}

void solve() {
	res = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (garden[i][j] == '#') {
				dfs(i, j, '#');
				res++;
			}
			if (garden[i][j] == '*') {
				dfs(i, j, '*');
				res++;
			}
			if (garden[i][j] == '@') {
				dfs(i, j, '@');
				res++;
			}
		}
	} 
	cout<<res<<endl;
	//从不是'.'的地方 开始填充
}

int main() {
	while(2333) {
		//判断输入结束 
		cin>>H>>W;
		if (H * W == 0) return 0;
		
		//输入前重置garden
		memset(garden, '.', sizeof(garden)); 
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) 
			cin>>garden[i][j];
		}  
		solve();
	}
}


