#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<vector<long long> > v(8, vector<long long>(8, 0));
  bool colum = true, fil = true;
  long long contac = 0, contaf = 0;
  for (long long j = 0; j < 8; j++) {
    long long conta = 0;
    for (long long i = 0; i < 8; i++) {
      char p;
      cin >> p;
      if (p == 'B') {
        v[j][i] = 0;
        conta++;
      } else {
        v[j][i] = 1;
      }
    }
    if (conta < 8) {
      colum = false;
      fil = false;
      contac = conta;
    } else {
      contaf++;
    }
  }
  if (fil) {
    cout << "8";
  } else {
    cout << contaf + contac;
  }
}
