#include <bits/stdc++.h>
char s[8][8];
int main() {
  int count = 0, x = 0, max = 0;
  for (int i = 0; i < 8; i++) {
    scanf("%s", s[i]);
    x = 0;
    for (int j = 0; j < 8; j++)
      if (s[i][j] == 'B') x++;
    if (x == 8)
      count++;
    else
      max = x > max ? x : max;
  }
  printf("%d\n", count + max);
}
