#include <bits/stdc++.h>
using namespace std;
int oneNum(int mask) {
  int ans = 0;
  while (mask > 0) {
    mask = mask & (mask - 1);
    ans++;
  }
  return ans;
}
int run() {
  vector<string> vb(8, "WWWWWWWW");
  vector<string> client;
  for (int i = 0; i < 8; i++) {
    string st;
    cin >> st;
    client.push_back(st);
  }
  int ans = 16;
  for (int mask = 0; mask < (1 << 16); mask++) {
    vector<string> vt = vb;
    for (int row = 0; row < 8; row++) {
      if ((1 << row) & mask) {
        for (int col = 0; col < 8; col++) vt[row][col] = 'B';
      }
    }
    for (int col = 0; col < 8; col++) {
      int shift = col + 8;
      if ((1 << shift) & mask) {
        for (int row = 0; row < 8; row++) vt[row][col] = 'B';
      }
    }
    if (vt == client) ans = min(ans, oneNum(mask));
  }
  printf("%d\n", ans);
  return 0;
}
int main(int argc, char* argv[]) {
  run();
  return 0;
}
