#include <cstdio>

char table[101][101];
int H, W;

void rec(int i, int j, char ch){
	table[i][j] = '.';
	if(table[i+1][j] == ch) rec(i+1, j, ch);
	if(table[i-1][j] == ch) rec(i-1, j, ch);
	if(table[i][j+1] == ch) rec(i, j+1, ch);
	if(table[i][j-1] == ch) rec(i, j-1, ch);

	return;
}
int main(){
	int count = 0;
	scanf("%d %d", &H, &W);
	for(int i = 0; i < H; i++){
		scanf("%s", &table[i]);
	}
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(table[i][j] != '.'){
				rec(i, j, table[i][j]);
				count++;
			}
		}
	}
	printf("%d\n", count);
	
	return 0;
}