#include<iostream>
#include<cstring>

char field[102][102];

void dfs(int r,int c,char type);

int main()
{
	int h,w;
	int areanum;
	char buf[128];
	
	while(1)
	{
		std::cin>>h>>w;
		if(h==0&&w==0)break;
		std::cin.ignore();
		
		memset(field,0,sizeof(field));
		
		for(int i=1;i<=h;i++)
		{
			std::cin.getline(buf,128);
			for(int j=1;j<=w;j++)
			{
				field[i][j]=buf[j-1];
			}
		}
		
		areanum=0;
		for(int i=1;i<=h;i++)
		{
			for(int j=1;j<=w;j++)
			{
				if(field[i][j]!=0)
				{
					dfs(i,j,field[i][j]);
					areanum++;
				}
			}
		}
		std::cout<<areanum<<std::endl;
	}
	return 0;
}

void dfs(int i,int j,char type)
{
	field[i][j]=0;
	if(field[i][j-1]==type)dfs(i,j-1,type);
	if(field[i][j+1]==type)dfs(i,j+1,type);
	if(field[i-1][j]==type)dfs(i-1,j,type);
	if(field[i+1][j]==type)dfs(i+1,j,type);
}