#include<cstdio>
#include<iostream>
using namespace std;
const int MAX_N = 100;
char room[MAX_N][MAX_N];
int w,h;
int next[4][2] = {
	{0,1},{1,0},{0,-1},{-1,0}
};
void dfs(int x,int y,char c)
{
	room[x][y] = '.';
	for(int k = 0 ; k < 4 ; k++)
	{
		int dx = x + next[k][0];
		int dy = y + next[k][1];
		if(dx >= 0 && dx < h && dy >= 0 && dy < w && room[dx][dy] == c)
		{
			dfs(dx,dy,c);
		}
	}
}
int main()
{
	while(cin >> h >> w, w > 0)
	{
		int result = 0;
		for(int i = 0 ; i < h ; i++)
		{
			scanf("%s",room[i]);
		}
		for(int i = 0 ; i < h ; i++)
			for(int j = 0 ; j < w ; j++)
			{
				if(room[i][j] != '.')
				{
					dfs(i,j,room[i][j]);
					result++;
				}
			}
		printf("%d\n",result);
	}
	return 0;
}
