#include <bits/stdc++.h>
using namespace std;
template <class _T>
_T MAX(_T a, _T b) {
  return a > b ? a : b;
}
template <class _T>
_T MIN(_T a, _T b) {
  return a < b ? a : b;
}
char board[16][16];
int main(void) {
  int ans = 0;
  for (int i = 0; i < 8; ++i) scanf("%s", board[i]);
  for (int i = 0; i < 8; ++i) {
    ans += string(board[i]) == "BBBBBBBB";
    string col = "";
    for (int j = 0; j < 8; ++j) col.push_back(board[j][i]);
    ans += col == "BBBBBBBB";
  }
  printf("%d\n", ans >> (ans == 16));
  return 0;
}
