#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  vector<int> ii(8);
  vector<int> jj(8);
  for (int i = 0; i < 8; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < 8; j++) {
      if (s[j] == 'B') {
        ii[i]++;
        jj[j]++;
      }
    }
  }
  int count = 0;
  for (auto num : ii) {
    if (num == 8) {
      count++;
    }
  }
  for (auto num : jj) {
    if (num == 8) {
      count++;
    }
  }
  if (count == 16) {
    cout << 8 << '\n';
    return 0;
  }
  cout << count << '\n';
  return 0;
}
