#include <bits/stdc++.h>
int main() {
  int x, y, i, j, yac = 0;
  char lab[8][8];
  for (i = 0; i < 8; i++)
    for (j = 0; j < 8; j++) scanf(" %c", &lab[i][j]);
  for (i = 0; i < 8; i++)
    for (j = 0; j < 8; j++) {
      if (lab[i][j] == 'B')
        ;
      else
        break;
      if (j == 7) yac++;
    }
  for (i = 0; i < 8; i++)
    for (j = 0; j < 8; j++) {
      if (lab[j][i] == 'B')
        ;
      else
        break;
      if (j == 7) yac++;
    }
  if (yac == 16) {
    yac = 8;
  }
  printf("%d\n", yac);
  return 0;
}
