#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[8][8];
  for (int i = 0; i < 8; i++) {
    scanf("%s", &str[i]);
  }
  int sum = 0;
  for (int k = 0; k < 8; k++) {
    if (str[0][k] == 'B') {
      int x = 0;
      for (int c = 1; c < 8; c++) {
        if (str[c][k] != 'B') {
          x = 1;
          break;
        }
      }
      if (x == 0) {
        sum++;
      }
    }
    if (str[k][0] == 'B') {
      int t = 0;
      for (int v = 1; v < 8; v++) {
        if (str[k][v] != 'B') {
          t = 1;
          break;
        }
      }
      if (t == 0) {
        sum++;
      }
    }
  }
  if (sum == 16) {
    sum = sum / 2;
  }
  printf("%d\n", sum);
}
