#include <bits/stdc++.h>
using namespace std;
char a[111][111];
void dfs(int x, int y) {
  a[x][y] = '.';
  if (a[x][y + 1] != '.') dfs(x, y + 1);
  if (a[x][y - 1] != '.') dfs(x, y - 1);
  if (a[x + 1][y] != '.') dfs(x + 1, y);
  if (a[x - 1][y] != '.') dfs(x - 1, y);
}
int main() {
  int n, m;
  cin >> n >> m;
  for (long long i = 0; i < 111; i++)
    for (long long j = 0; j < 111; j++) a[i][j] = '.';
  for (long long i = 1; i < n + 1; i++)
    for (long long j = 1; j < m + 1; j++) cin >> a[i][j];
  int ans = 0;
  for (long long i = 1; i < n + 1; i++)
    for (long long j = 1; j < m + 1; j++) {
      if (a[i][j] == '.') continue;
      dfs(i, j);
      ans++;
    }
  cout << ans;
  return 0;
}
