#include<cstdio>
#define MAX_H 100
#define MAX_W 100
int H, W;
char fields[MAX_W + 1][MAX_H] = { };
int dx[4] = { -1, 1, 0, 0 }, dy[4] = {0, 0, -1, 1};

void
dfs (int x, int y)
{
  char ch = fields[x][y];
  fields[x][y] = '.';
  for (int i = 0; i < 4; i++)
    {
      int nx = x + dx[i], ny = y + dy[i];
      if (0 <= nx && nx < W && 0 <= ny && ny < H && ch == fields[nx][ny])
		dfs (nx, ny);
    }
}
int
main (void)
{
  while (EOF != scanf ("%d %d\n", &H, &W))
    {
      if (H == 0 && W == 0)
	return 0;
      for (int y = 0; y < H; y++)
	for (int x = 0; x <= W; x++)
	    scanf ("%c", &fields[x][y]);
      int count = 0;
      for (int y = 0; y < H; y++)
	for (int x = 0; x < W; x++)
	  {
	    if ('.' != fields[x][y])
	      {
		dfs (x, y);
		count++;
	      }
	  }
      printf ("%d\n", count);
    }
  return 0;
}