#include <bits/stdc++.h>
using namespace std;
char d[8][8];
int i, j, sch, k, m;
int main() {
  k = 0;
  m = 0;
  for (i = 0; i < 8; i++) {
    sch = 0;
    for (j = 0; j < 8; j++) {
      cin >> d[i][j];
      if (d[i][j] == 'B') sch++;
    }
    if (sch == 8)
      k++;
    else if (sch > m)
      m = sch;
  }
  cout << k + m;
  return 0;
}
