#include <bits/stdc++.h>
int main() {
  int i, j, ri, rj, count = 0, counti, countj, counta = 0, countb = 0;
  char str[9][9];
  for (i = 0; i < 8; i++) {
    scanf(" %s", str[i]);
    if (strcmp(str[i], "BBBBBBBB") == 0) counta++;
  }
  if (counta == 8) {
    printf("8\n");
    return 0;
  }
  for (j = 0; j < 8; j++) {
    counti = 0;
    for (i = 0; i < 8; i++) {
      if (str[i][j] == 'B') {
        counti++;
      }
    }
    if (counti == 8) countb++;
  }
  printf("%d\n", counta + countb);
  return 0;
}
