#include <bits/stdc++.h>
using namespace std;
int main() {
  char mat[15][15];
  int n = 8;
  for (int i = 0; i < n; ++i) scanf("%s", &mat[i]);
  int ans = 0, full = 0;
  for (int i = 0; i < n; ++i) {
    int cnt1 = 0, cnt2 = 0;
    for (int j = 0; j < n; ++j) {
      full += (mat[i][j] == 'B');
      cnt1 += (mat[i][j] == 'B');
      cnt2 += (mat[j][i] == 'B');
    }
    ans += (cnt1 == 8) + (cnt2 == 8);
  }
  if (full == n * n) ans = 8;
  printf("%d\n", ans);
  return 0;
}
