#include <bits/stdc++.h>
using namespace std;
char a[10][10];
int ans;
bool ok;
inline void read(int &x) {
  int f;
  char c;
  for (f = 1, c = getchar(); c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
  x *= f;
}
inline int mn(int _x, int _y) { return _x < _y ? _x : _y; }
inline int mx(int _x, int _y) { return _x > _y ? _x : _y; }
inline int ab(int _x) {
  if (_x < 0)
    return -_x;
  else
    return _x;
}
int main() {
  for (int i = 1; i <= 8; i++) scanf("%s", 1 + a[i]);
  for (int i = 1; i <= 8; i++) {
    ok = true;
    for (int j = 1; j <= 8; j++)
      if (a[i][j] != 'B') {
        ok = false;
        break;
      }
    if (ok) ans++;
  }
  for (int i = 1; i <= 8; i++) {
    ok = true;
    for (int j = 1; j <= 8; j++)
      if (a[j][i] != 'B') {
        ok = false;
        break;
      }
    if (ok) ans++;
  }
  if (ans == 16) ans = 8;
  printf("%d\n", ans);
  return 0;
}
