#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[8][8];
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      cin >> s[i][j];
    }
  }
  int sum2 = 0;
  int sum3 = 0;
  for (int i = 0; i < 8; i++) {
    int sum1 = 0;
    for (int j = 0; j < 8; j++) {
      if (s[i][j] == 'B') sum1++;
    }
    if (sum1 == 8)
      sum2++;
    else
      sum3 = sum1;
  }
  cout << sum2 + sum3 << endl;
  return 0;
}
