#include <bits/stdc++.h>
using namespace std;
int main() {
  int num = 0;
  char array[9][9];
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) cin >> array[i][j];
  }
  if (array[0][0] == 'B') {
    int jcheck = 1;
    int icheck = 1;
    for (int i = 0; i < 8; i++) {
      if (array[0][i] == 'W') jcheck = 0;
      if (array[i][0] == 'W') icheck = 0;
    }
    if (icheck) num++;
    if (jcheck) num++;
  }
  for (int i = 1; i < 8; i++) {
    if (array[0][i] == 'B') {
      int check = 1;
      for (int j = 1; j < 8; j++) {
        if (array[j][i] == 'W') check = 0;
      }
      if (check) num++;
    }
  }
  for (int i = 1; i < 8; i++) {
    if (array[i][0] == 'B') {
      int check = 1;
      for (int j = 1; j < 8; j++) {
        if (array[i][j] == 'W') check = 0;
      }
      if (check) num++;
    }
  }
  if (num == 16) num = 8;
  printf("%d\n", num);
  return 0;
}
