#include <iostream>

using namespace std;
char field[102][102];
int dx[4] = {-1, 0, 1,  0};
int dy[4] = { 0, 1, 0, -1};

void DFS(int y, int x, char c)
{
	field[y][x] = '.';
	for(int i = 0; i < 4; ++i)
	{
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(field[ny][nx] == c)
		{
			DFS(ny, nx, c);
		}
	}
}

void solve()
{
	int H, W;
	while(cin >> H >> W, H || W)
	{
		for(int i = 1; i <= H; ++i)
		{
			for(int j = 1; j <= W; ++j)
			{
				cin >> field[i][j];
			}
		}
		int count = 0;
		for(int i = 1; i <= H; ++i)
		{
			for(int j = 1; j <= W; ++j)
			{
				if(field[i][j] != '.')
				{
					++count;
					DFS(i, j, field[i][j]);
				}
			}
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}