#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> m(8);
  for (int i = 0; i < 8; ++i) getline(cin, m[i]);
  int minBc = 16;
  for (int y = 0; y < 256; ++y)
    for (int x = 0; x < 256; ++x) {
      int bc = __builtin_popcount(x) + __builtin_popcount(y);
      if (minBc <= bc) continue;
      vector<string> mm(8, string(8, 'W'));
      for (int i = 0; i < 8; ++i)
        for (int j = 0; j < 8; ++j)
          if ((y & (1 << i)) || (x & (1 << j))) mm[i][j] = 'B';
      if (m == mm) minBc = bc;
    }
  cout << minBc << endl;
}
