#include <iostream>
using namespace std;

char F[102][102];

void DFS(int Y,int X,char c){
  if(F[Y][X]!=c){
    return;
  }

  F[Y][X] = c;

  DFS(Y-1,X  ,c);
  DFS(Y-1,X+1,c);
  DFS(Y  ,X+1,c);
  //DFS(Y+1,X+1,c);
  DFS(Y+1,X  ,c);
  //DFS(Y+1,X-1,c);
  DFS(Y  ,X-1,c);
  DFS(Y-1,X-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,'@');
      }
    }
  }
  for(int y=1;y<=N;y++){
    for(int x=1;x<=M;x++){
      if(F[y][x]=='#'){
        cnt++;
        DFS(y,x,'#');
      }
    }
  }
  for(int y=1;y<=N;y++){
    for(int x=1;x<=M;x++){
      if(F[y][x]=='*'){
        cnt++;
        DFS(y,x,'*');
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

