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

char field[102][102];
char now;

void DFS(int xx,int yy)
{
	field[yy][xx] = '.';
	if(now==field[yy-1][xx])
		DFS(xx,yy-1);
	if(now==field[yy+1][xx])
		DFS(xx,yy+1);
	if(now==field[yy][xx-1])
		DFS(xx-1,yy);
	if(now==field[yy][xx+1])
		DFS(xx+1,yy);
	
}
int main()
{
	int x,y;
	while(cin >> y >> x){
		if(!x&&!y)
			break;
		memset(field,'.',sizeof(field));
		for(int i=1;i<=y;i++){
			for(int j=1;j<=x;j++){
				cin >> field[i][j];
			}
		}
		int count = 0;
		for(int i=1;i<=y;i++){
			for(int j=1;j<=x;j++){
				if(field[i][j]!='.'){
					count++;
					now = field[i][j];
					DFS(j,i);
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}