#include <iostream>

const int MAX = 100;
int W, H;
char matrix[MAX][MAX];
const char VISITED = 'v';
int dirx[4] = {1, 0, -1, 0};
int diry[4] = {0, 1, 0, -1};

void dfs(int i, int j, char c)
{
  if (i < 0 || i >= H || j < 0 || j >= W || matrix[i][j] != c)
  {
    return;
  }
  matrix[i][j] = VISITED;
  for (int k = 0; k < 4; k++)
  {
    dfs(i + dirx[k], j + diry[k], c);
  }
}

int main()
{
  while (true)
  {
    std::cin >> H;
    std::cin >> W;
    if (H == 0 && W == 0)
    {
      break;
    }
    for (int i = 0; i < H; i++)
    {
      for (int j = 0; j < W; j++)
      {
        std::cin >> matrix[i][j];
      }
    }
    int count = 0;
    for (int i = 0; i < H; i++)
    {
      for (int j = 0; j < W; j++)
      {
        if (matrix[i][j] == VISITED)
        {
          continue;
        }
        count += 1;
        dfs(i, j, matrix[i][j]);
      }
    }
    std::cout << count << std::endl;
  }
  return 0;
}
