#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
bool ariv[101][101];
static const int dx[4] = {1,0,-1,0};
static const int dy[4] = {0,-1,0,1};
int H,W;
void dfs(vector<string> grid, int x, int y, char s){
  ariv[y][x] = true;
  REP(r,4){
    if(x+dx[r]>=0&&x+dx[x]<W&&y+dy[r]>=0&&y+dy[r]<H&&ariv[y+dy[r]][x+dx[r]]==false
        &&grid[y][x]==s){
      dfs(grid,x+dx[r],y+dy[r],s);
    }
  }
}
int main(void){
  while(cin>>H>>W){
    if(H==0) break;
    vector<string> grid;
    memset(ariv,0,sizeof(ariv));
    REP(i,H){
      string tmp;
      cin>>tmp;
      grid.push_back(tmp);
    }
    int ans = 0;
    REP(y,H)REP(x,W){
      if(ariv[y][x]==false){
        ans++;
        dfs(grid,x,y,grid[y][x]);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}