#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, ans = 0, count = 0, cont[10];
  char a[10][10];
  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'B') count++;
    }
    if (count == 8) ans++;
    count = 0;
  }
  if (ans < 8)
    for (i = 0; i < 8; i++) {
      for (j = 0; j < 8; j++) {
        if (a[j][i] == 'B') count++;
      }
      if (count == 8) ans++;
      count = 0;
    }
  cout << ans << endl;
  cin.get();
  return 0;
}
