#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/

int H, W;
char field[110][110];

int hi[4] = { -1,0,0,1 };
int wi[4] = { 0,-1,1,0 };

void del(int h, int w, char c)
{
	field[h][w] = '.';

	for (int i = 0; i < 4; i++)
	{
		if (field[max(min(h + hi[i], H - 1), 0)][max(min(w + wi[i], W - 1), 0)] == c)
			del(max(min(h + hi[i], H - 1), 0), max(min(w + wi[i], W - 1), 0), c);
	}
}

int main()
{	
	while (true)
	{
		cin >> H >> W;
		if (H == 0 && W == 0) break;

		for (int i = 0; i < H; i++)
		{
			cin >> field[i];
		}

		int ans = 0;

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (field[i][j] != '.')
				{
					del(i, j, field[i][j]);
					ans++;
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

