#include <iostream>
#include <cstdio>
using namespace std ;

int h , w ;
char Map[110][110];
int move[4][2] = {-1,0,1,0,0,1,0,-1};


void dfs(int x ,int y ,char aim)
{
	Map[x][y] = '!';
	for (int i=0; i<4;i++)
	{
		int X = x + move[i][0];
		int Y = y+ move[i][1];
		if (X <0 || X >=h || Y<0|| Y>=w || Map[X][Y]!=aim) continue;
		dfs(X ,Y , aim);
	}
}

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