#include <bits/stdc++.h>
using namespace std;
int main() {
  int l[8], c[8];
  memset(c, 0, sizeof c);
  memset(l, 0, sizeof l);
  char a;
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      cin >> a;
      if (a == 'B') {
        l[i]++;
        c[j]++;
      }
    }
  }
  int cont = 0;
  for (int i = 0; i < 8; ++i) {
    if (l[i] == 8) cont++;
    if (c[i] == 8) cont++;
  }
  if (cont == 16) cont = 8;
  cout << cont << endl;
  return 0;
}
