#include <bits/stdc++.h>
using namespace std;
char a[8][8];
int ans = 0, i, j;
int main() {
  for (i = 0; i < 8; ++i) scanf("%s", a[i]);
  for (i = 0; i < 8; ++i) {
    bool f = 1;
    for (j = 0; j < 8; ++j) {
      if (a[i][j] != 'B') f = 0;
    }
    if (f) ++ans;
  }
  for (i = 0; i < 8; ++i) {
    bool f = 1;
    for (j = 0; j < 8; ++j) {
      if (a[j][i] != 'B') f = 0;
    }
    if (f) ++ans;
  }
  if (ans == 16) ans = 8;
  printf("%d", ans);
  return 0;
}
