#include <iostream>
using namespace std;
const int MAX_H =100,MAX_W =100;
const int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

char field[MAX_H][MAX_W];
int h,w;
int ans;

void dfs(int x, int y, char k)
{
	field[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 && field[ny][nx] == k){
			dfs(nx,ny,k);
		}
	}
}


int main()
{
	while(1){
		ans = 0;
		cin >> h >> w;
		if(h == 0 && w == 0)break;
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				cin >> field[i][j];
			}
		}
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(field[i][j] != '.'){
					++ans;
					dfs(j,i,field[i][j]);
				}
			}
		}
		cout << ans << endl;
	}
}