#include <bits/stdc++.h>
using namespace std;
void solve() {
  char a[8][8];
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      cin >> a[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < 8; i++) {
    if (a[i][0] == 'B') {
      bool ban = true;
      for (int j = 0; j < 8; j++) {
        if (a[i][j] != 'B') {
          ban = false;
        }
      }
      if (ban) {
        ans++;
      }
    }
  }
  for (int i = 0; i < 8; i++) {
    if (a[0][i] == 'B') {
      bool ban = true;
      for (int j = 0; j < 8; j++) {
        if (a[j][i] != 'B') {
          ban = false;
        }
      }
      if (ban) {
        ans++;
      }
    }
  }
  if (ans == 16) {
    ans /= 2;
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
