#include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<climits>

#include<iomanip>
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<sstream>
#include<map>
#include<set>
#include<utility>
#include<queue>

using namespace std;
const int MAX = 101;
char f[MAX][MAX];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
void dfs(int x,int y){
  char fruit = f[x][y];
  f[x][y] = '.';
  for(int i = 0;i < 4;i++){
    int nx = x+dx[i],ny = y+dy[i];
    if(fruit == f[nx][ny])dfs(nx,ny);
  }
}
int main(){
  ios::sync_with_stdio(false);
  int w,h;
  fill(*f, *(f+MAX), '.');
  while(cin >> w >> h && (w+h) > 0){
    for (int i = 1; i <= h; ++i){
      for (int j = 1; j <= w; ++j){
	cin >> f[j][i];
      }
    }
    int cnt = 0;
    for (int i = 1; i <= h; ++i){
      for (int j = 1; j <= w; ++j){
	if(f[j][i] != '.'){
	  dfs(j,i);
	  cnt++;
	}
      }
    }
    cout << cnt << endl;
  }

  return 0;
}