#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const long long nmax = 1e5 + 3;
const long long inf = 1e14;
using namespace std;
void kimusik() {
  char a[8][8];
  for (long long i = 0; i < 8; i++)
    for (long long j = 0; j < 8; j++) cin >> a[i][j];
  long long ans = 0;
  for (long long i = 0; i < 8; i++) {
    long long nr = 0;
    for (long long j = 0; j < 8; j++)
      if (a[i][j] == 'B') nr++;
    if (nr == 8) ans++;
  }
  if (ans < 8)
    for (long long i = 0; i < 8; i++) {
      long long nr = 0;
      for (long long j = 0; j < 8; j++)
        if (a[j][i] == 'B') nr++;
      if (nr == 8) ans++;
    }
  cout << ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) kimusik();
  return 0;
}
