#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2, class T3, class T4, class T5, class T6>
void debt6(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
bool arr[9][9];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n, cnt = 0;
  char ch;
  string str[10];
  for (int i = 0; i < 8; i++) {
    cin >> str[i];
  }
  for (int i = 0; i < 8; i++) {
    int j = 0;
    while (str[i][j] == 'B' and j < 8) {
      j++;
    }
    if (j == 8) cnt++;
  }
  for (int i = 0; i < 8; i++) {
    int j = 0;
    while (str[j][i] == 'B' and j < 8) {
      j++;
    }
    if (j == 8) cnt++;
  }
  if (cnt == 16)
    cout << 8 << endl;
  else
    cout << cnt << endl;
  return 0;
}
