
#include <iostream>
#include <cstring>
using namespace std;
int vis[100][100];
char map[100][100];
int direction[4][2] = { -1, 0,0, -1,1, 0, 0, 1 };
int H, W;

void dfs(const int x,const int y,const char c)
{
	vis[x][y] = 1;
	for (int i = 0; i < 4; i++)
	{
		int xx = x + direction[i][0];
		int yy = y + direction[i][1];
		if (xx>=0&&yy>=0&&xx<H&&yy<W &&vis[xx][yy]!=1&&c == map[xx][yy])
		{
			
			dfs(xx, yy,c);
		}
	}
}

int main()
{
	while (cin >> H >> W&&H != 0 && W != 0)
	{
		int sum = 0;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> map[i][j];
			}
		}
		for (int i = 0; i<H; i++)
		for (int j = 0; j<W; j++)
		if (vis[i][j]!=1)
		{
			
			dfs(i,j,map[i][j]);sum++;
		}

		cout << sum << endl;

	}
	return 0;
}