#include <iostream>
using namespace std;

char F[100][100];

void DFS(int H, int W, char c){
  if(F[H][W]!=c)
    return;

  F[H][W] = '.';

  DFS(H-1, W  ,c);
  DFS(H  , W+1,c);
  DFS(H+1, W  ,c);
  DFS(H  , W-1,c);
}

int main(){
  int N,M;
  cin >> N >> M;
  for(int y=1; y<=N; y++)
    for(int x=1; x<=M; x++)
      cin >> F[y][x];

  int cnt = 0;
  for(int y=1; y<=N; y++)
    for(int x=1; x<=M; x++)
      if(F[y][x]!='.'){
        cnt++;
        DFS(y, x, F[y][x]);
      }
  cout << cnt << endl;

  return 0;
}

