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