#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  vector<string> lines(8);
  for (int i = 0; i < 8; i++) {
    cin >> lines[i];
  }
  string pat = string(8, 'B');
  int cnt = 0;
  for (int i = 0; i < 8; i++) {
    cnt += lines[i] == pat;
  }
  if (cnt != 8)
    for (int j = 0; j < 8; j++) {
      string col;
      for (int i = 0; i < 8; i++) {
        col += lines[i][j];
      }
      cnt += col == pat;
    }
  cout << cnt << '\n';
  return 0;
}
