#include <bits/stdc++.h>
using namespace std;
int n, m, i, j;
char a[105][105];
bool mark[105][105];
int answ;
queue<pair<int, int> > q;
int dx[5] = {0, 0, 1, -1}, dy[5] = {1, -1, 0, 0};
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> a[i][j];
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (a[i][j] == '.') continue;
      if (mark[i][j] == 1) continue;
      answ++;
      q.push(make_pair(i, j));
      while (!q.empty()) {
        int x = q.front().first, y = q.front().second;
        q.pop();
        for (int h = 0; h < 4; h++) {
          int norx = x + dx[h], nory = y + dy[h];
          if (norx < 1 || norx > n || nory < 1 || nory > m) continue;
          if (a[norx][nory] == '.' || mark[norx][nory] == 1) continue;
          q.push(make_pair(norx, nory));
          mark[norx][nory] = 1;
        }
      }
    }
  }
  cout << answ << endl;
  return 0;
}
