/************************************************
* Author        :somniloquy
* Created Time  :2015/10/30 14:00:50
 ************************************************/

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>

using namespace std;
const int hw_max = 100 + 5;
char graph[hw_max][hw_max];
int sign[hw_max][hw_max];
int h, w, ans;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
struct node
{
	int x;
	int y;
	char mark;
} start;

void dfs(node now)
{
	for(int i = 0; i < 4; i ++)
	{
		node next = now;
		next.x += dx[i];
		next.y += dy[i];
		if(next.mark == graph[next.x][next.y] && !sign[next.x][next.y])
		{
			sign[next.x][next.y] = 1;
			dfs(next);
		}
	}
}

int main(void)
{
	while(~scanf("%d %d", & h, & w))
	{
		getchar();
		if(!h && !w)
			break;
		memset(graph, 0, sizeof(graph));
		ans = 0;
		for(int i = 0; i < h; i ++)
		{
			for(int j = 0; j < w; j ++)
				scanf("%c", & graph[i][j]);
			getchar();
		}
		for(int i = 0; i < h; i ++)
		{
			for(int j = 0; j < w; j ++)
			{
				if(!sign[i][j])
				{
					start.x = i;
					start.y = j;
					start.mark = graph[i][j];
					dfs(start);
					ans ++;
				}
			}
		}
		printf("%d\n", ans);
	}
        return 0;
}