#include <bits/stdc++.h>
using namespace std;
char d[10][10];
int r, c = 8, cnt, ans;
int main(int argc, const char* argv[]) {
  for (int i = 1; i <= 8; ++i) {
    cnt = 0;
    for (int j = 1; j <= 8; ++j) {
      cin >> d[i][j];
      if (d[i][j] == 'B') {
        cnt++;
      }
    }
    if (cnt == 8) r++;
    c = min(c, cnt);
  }
  ans = r + c;
  if (r == 8) ans = 8;
  printf("%d\n", ans);
  return 0;
}
