#include <bits/stdc++.h>
using namespace std;
vector<string> board;
bool check(int mask1, int mask2) {
  char brd[8][8];
  for (int i = (int)(0); i <= (int)(7); ++i)
    for (int j = (int)(0); j <= (int)(7); ++j) brd[i][j] = 'W';
  int pos1 = 0, pos2 = 0;
  while (mask1 > 0 || mask2 > 0) {
    if ((mask1 & 1) == 1) {
      for (int i = (int)(0); i <= (int)(7); ++i) brd[i][pos1] = 'B';
    }
    if ((mask2 & 1) == 1) {
      for (int i = (int)(0); i <= (int)(7); ++i) brd[pos2][i] = 'B';
    }
    mask1 >>= 1;
    mask2 >>= 1;
    pos1++;
    pos2++;
  }
  for (int i = (int)(0); i <= (int)(7); ++i)
    for (int j = (int)(0); j <= (int)(7); ++j)
      if (board[i][j] != brd[i][j]) return false;
  return true;
}
int main() {
  for (int i = (int)(0); i <= (int)(7); ++i) {
    string tmp;
    cin >> tmp;
    board.push_back(tmp);
  }
  int result = 16;
  for (int i = (int)(0); i <= (int)(255); ++i)
    for (int j = (int)(0); j <= (int)(255); ++j)
      if (check(i, j)) {
        int sum = 0;
        int mask1 = i, mask2 = j;
        while (mask1 > 0 || mask2 > 0) {
          if ((mask1 & 1) == 1) sum++;
          if ((mask2 & 1) == 1) sum++;
          mask1 >>= 1;
          mask2 >>= 1;
        }
        result = ((result) < (sum) ? (result) : (sum));
      }
  cout << result;
  return 0;
}
