#include <iostream>
using namespace std;
char m[100][101];
int h, w;
void dfs(int x, int y, char c)
{
	int i, j, nx, ny, dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
	m[y][x] = '.';
	for (i = 0; i < 4; i++)
	{
		nx = x + dx[i];
		ny = y + dy[i];
		if (0 <= nx && nx < w && 0 <= ny && ny < h && m[ny][nx] == c) dfs(nx, ny, c);
	}
	return;
}
int main()
{
	int i, j, n;
	while (cin >> h >> w)
	{
		if (h == 0 && w == 0) break;
		for (i = 0; i < h; i++)
		{
			cin >> m[i];
			if (cin.eof()) return 0;
		}
		n = 0;
		for (i = 0; i < h; i++)
		{
			for (j = 0; j < w; j++)
			{
				if (m[i][j] != '.')
				{
					n++;
					dfs(j, i, m[i][j]);
				}
			}
		}
		cout << n << endl;
	}
}