#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> inp;
  string second;
  for (int i = 0; i < 8; i++) {
    cin >> second;
    inp.push_back(second);
  }
  int ans = 0;
  for (int i = 0; i < 8; i++) {
    int cnt = 0;
    for (int j = 0; j < 8; j++) {
      if (inp[i][j] == 'B') cnt++;
    }
    if (cnt == 8) ans++;
  }
  if (ans != 8) {
    for (int i = 0; i < 8; i++) {
      int cnt = 0;
      for (int j = 0; j < 8; j++) {
        if (inp[j][i] == 'B') cnt++;
      }
      if (cnt == 8) ans++;
    }
  }
  cout << ans;
  return 0;
}
