#include <cstdio>
#include <vector>

using namespace std;

char s[100][100];

int H, W;

void dfs(int i, int j, char c)
{
	if (i>=0 && i<H && j>=0 && j<W && s[i][j]==c) {
		s[i][j] = '\0';
		dfs(i-1, j, c);
		dfs(i+1, j, c);
		dfs(i, j-1, c);
		dfs(i, j+1, c);
	}
}


int main()
{
	//freopen("in.txt", "r", stdin);

	while (scanf("%d%d", &H, &W)==2) {
		if (H==0 && W==0) break;
		int i, j;
		for (i=0; i<H; i++) {
			for (j=0; j<W; j++) {
				char c;
				do { c=getchar(); } while (c!='@' && c!='#' && c!='*');
				s[i][j] = c;
			}
		}

		int count = 0;
		for (i=0; i<H; i++) {
			for (j=0; j<W; j++) {
				if (s[i][j]!='\0') {
					count++;
					dfs(i, j, s[i][j]);
				}
			}
		}
		printf("%d\n", count);

	}

	return 0;
}