#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;

const int M = 186;

int n;
int m;
char g[M][M];
int dir[4][2] = {{0,-1},{0,1},{-1,0},{1,0}};

void dfs(int x,int y,char k)
{
	int i;
	int dx;
	int dy;
	for(i = 0 ;i < 4; i++)
	{
		dx = x+dir[i][0];
		dy = y+dir[i][1];
		if( 0<=dx < n && 0 <= dy < m && g[dx][dy] == k)
		{
			g[dx][dy] = 'b';
			dfs(dx,dy,k);
		}
	}
}

void solve()
{
	int i;
	int j;
	int count = 0;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		if(n == 0 && m == 0)
		{
			break;
		}
		count = 0;
		for(i=0;i<n;i++)
		{
			scanf("%s",g[i]);
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				if(g[i][j]!='b')
				{
					dfs(i,j,g[i][j]);
					count++;
				}
			}
		}
		cout<<count<<endl;
	}
}

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