#include<iostream>  
 
using namespace std;  
   
char table[100][100];  
int W, H;  
const int direction[4][2] = {{ -1, 0 },  { 1, 0 },  { 0, -1 },  { 0, 1 }};  
   
void dfs(int x, int y, char cur)  
{  
  table[x][y] = 'x';  
  for (int i = 0; i < 4; ++i)  
  {  
    int nx = x + direction[i][0];  
    int ny = y + direction[i][1];  
    if (nx >= 0 && nx < W && ny >= 0 && ny < H && table[nx][ny] == cur)  
    {  
      dfs(nx, ny, cur);  
    }  
  }  
}  
   
int main()  
{  
   
  while (cin >> H >> W, W > 0)  
  {  
    int res = 0;  
    int x, y;  
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        cin >> table[x][y];  
      }  
    }  
   
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        if (table[x][y] != 'x')  
        {  
          dfs(x, y, table[x][y]);  
          ++res;  
        }  
      }  
    }  
    cout << res << endl;  
  }  
  return 0;  
} 