#include<cstdio>
int H, W;
char map[201][201];
int dx[4]{ 0, 0, 1, -1 };
int dy[4]{ 1, -1, 0, 0 };
int ans = 0;
void dfs(int x, int y,char ch)
{
	map[x][y] = '.';//把符号@，#，*其中一个替换成.。和poj1979很像，稍微改下1979的代码就行
	for (int i = 0; i < 4; i++)
	{
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx&&nx < H && 0 <= ny&&ny < W&&map[nx][ny] ==ch)dfs(nx, ny, ch);
	}
}
int main()
{
	scanf("%d%d", &H, &W);
	while (getchar() != '\n')continue;
	while (W&&H)
	{
		ans = 0;
		for (int i = 0; i < H; i++)
			gets(map[i]);
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++){
				if (map[i][j] == '#'){ dfs(i, j, '#'); ans++; }
				else if (map[i][j] == '@'){ dfs(i, j, '@'); ans++; }
				else if (map[i][j] == '*'){ dfs(i, j, '*') ; ans++; }
			}
		}
		printf("%d\n", ans);
		scanf("%d%d", &H, &W);
		while (getchar() != '\n')continue;

	}
    return 0;
}


