#include <bits/stdc++.h>
using namespace std;
const int maxn = 200;
int n, m;
char s[maxn][maxn];
int direct[8][2] = {
    1, -1, 1, 1, -1, 1, -1, -1, 0, 1, 0, -1, 1, 0, -1, 0,
};
void dfs(int x, int y) {
  s[x][y] = '.';
  for (int i = 0; i < 8; i++) {
    int xx = x + direct[i][0];
    int yy = y + direct[i][1];
    if (xx >= 0 && xx < n && yy >= 0 && yy < m && s[xx][yy] != '.') {
      dfs(xx, yy);
    }
  }
  return;
}
int main() {
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++) cin >> s[i];
    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (s[i][j] != '.') {
          dfs(i, j);
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
