#include <bits/stdc++.h>
int main() {
  int i, j, a = 0, b = 0, n, y;
  char x[10][10];
  for (i = 0; i < 8; i++) scanf("%s", x[i]);
  for (i = 0; i < 8; i++) {
    n = 0;
    for (j = 0; j < 8; j++) {
      if (x[i][j] == 'B') {
        n++;
      }
    }
    if (n == 8) a++;
  }
  for (i = 0; i < 8; i++) {
    n = 0;
    for (j = 0; j < 8; j++) {
      if (x[j][i] == 'B') {
        n++;
      }
    }
    if (n == 8) b++;
  }
  y = a + b;
  if (a == 8) y = 8;
  printf("%d", y);
  return 0;
}
