#include <cstdio>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <bitset>
#include <list>
#include <map>
#include <set>

#define mod 1000000007
#define MAXN 2005
typedef long long ll;
using namespace std;
//
char mapi[110][110];
int vis[110][110];
int h, w;
void dfs(int i,int j)
{
	char ch = mapi[i][j];
	vis[i][j] = 1;
	if (i+1<h&&mapi[i+1][j] == ch && vis[i+1][j] == 0) dfs(i+1, j);
	if (j+1<h&&mapi[i][j+1] == ch && vis[i][j+1] == 0) dfs(i, j+1);
	if (i-1>=0&&mapi[i-1][j] == ch && vis[i-1][j] == 0) dfs(i-1, j);
	if (j-1>=0&&mapi[i][j-1] == ch && vis[i][j-1] == 0) dfs(i, j-1);
}
int main()
{
	
	while (cin >> h >> w,h)
	{
		memset(mapi, 0, sizeof(mapi));
		memset(vis, 0, sizeof(vis));
		for (int i = 0; i < h; i++)
		{
			cin.ignore();
			for (int j = 0; j < w; j++)
				scanf("%c", &mapi[i][j]);
		}
		int ans = 0;
		for (int i = 0; i<h; i++)
			for (int j = 0; j < w; j++)
			{
				if (!vis[i][j])
				{
					dfs(i, j);
					ans++;
				}
			}
		cout << ans << endl;
	}
	//cin >> h;
	//cin >> n;
	return 0;
}

