#include <bits/stdc++.h>
int main() {
  char ss[1000][1000];
  int d, a, b, c, i, j, k = 0;
  for (i = 1; i <= 8; i++) {
    for (j = 1; j <= 8; j++) {
      scanf("%c", &ss[i][j]);
    }
    getchar();
  }
  for (i = 1; i <= 8; i++) {
    c = 0;
    d = 0;
    for (j = 1; j <= 8; j++) {
      if (ss[i][j] == 'B') {
        c++;
      }
      if (ss[j][i] == 'B') {
        d++;
      }
    }
    if (c == 8) {
      k++;
    }
    if (d == 8) {
      k++;
    }
  }
  if (k == 16) {
    printf("8\n");
  } else
    printf("%d\n", k);
  return 0;
}
