#include<iostream>
using namespace std;

char HW[102][102];

void DFS(int Y,int X,char c)
{
	char check=c;
	if(HW[Y][X]=='0'||HW[Y][X]!=check)
		return;

	HW[Y][X]='0';
	
	DFS(Y-1,X,c);
	DFS(Y,X+1,c);
	DFS(Y+1,X,c);
	DFS(Y,X-1,c);
}	
	
int main()
{
	int H,W;
	cin>>H>>W;

	for(int y=1;y<=H+1;y++){
		for(int x=1;x<=W;x++){
			cin>>HW[y][x];
			if(HW[y][x]=='0'&&HW[y][x-1]=='0'){
				break;
			}
		}
	}
	
	int count=0;
	for(int y=1;y<=H;y++){
		for(int x=1;x<=W;x++){
			if((HW[y][x]=='@')||(HW[y][x]=='#')||(HW[y][x]=='*')){
				count++;
				DFS(y,x,HW[y][x]);
			}
		}
	}
	
	cout<<count<<endl;

	return 0;
} 