#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str[8];
  for (int i = 0; i < 8; i++) {
    cin >> str[i];
  }
  int count = 0, a = 0;
  ;
  for (int i = 0; i < 8; i++) {
    int c = 0;
    for (int j = 0; j < 8; j++) {
      if (str[i][j] == 'B') {
        c++;
      }
    }
    if (c == 8)
      count++;
    else
      a = c;
  }
  cout << count + a << "\n";
  return 0;
}
