#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  char a[10][10];
  bool b[10][10] = {false};
  long long c = 0;
  for (long long i = 0; i < 8; i++) {
    for (long long j = 0; j < 8; j++) cin >> a[i][j];
  }
  for (long long i = 0; i < 8; i++) {
    long long p = 0;
    for (long long j = 0; j < 8; j++)
      if (a[i][j] == 'B') p++;
    if (p == 8) {
      c++;
      for (long long j = 0; j < 8; j++) b[i][j] = true;
    }
  }
  for (long long i = 0; i < 8; i++) {
    for (long long j = 0; j < 8; j++) {
      if (a[j][i] == 'B' && !b[j][i]) {
        c++;
        for (long long k = 0; k < 8; k++) b[k][i] = true;
      }
    }
  }
  cout << c;
}
