#include <bits/stdc++.h>
using namespace std;
int main() {
  char ch;
  int i, j, k = 0, p = 0, v = 0;
  for (i = 0; i < 8; i++) {
    k = 0;
    for (j = 0; j < 8; j++) {
      cin >> ch;
      if (ch == 'B') k++;
    }
    if (k == 8)
      p++;
    else
      v = max(v, k);
  }
  cout << (p + v) << endl;
  return 0;
}
