#include <bits/stdc++.h>
int main() {
  char b[16] = {0}, chess[8][8];
  for (int i = 0; i < 8; ++i) gets(chess[i]);
  for (int i = 0; i < 8; ++i)
    for (int j = 0; j < 8; ++j) {
      b[i] += chess[i][j] - 'B';
      b[j + 8] += chess[i][j] - 'B';
    }
  int t = 0;
  for (int i = 0; i < 16; ++i)
    if (!b[i]) ++t;
  printf("%d\n", t == 16 ? 8 : t);
  return 0;
}
