#include <bits/stdc++.h>
using namespace std;
int main() {
  int s = 0;
  char a[8][8];
  for (int i = 0; i < 8; ++i)
    for (int j = 0; j < 8; ++j) cin >> a[i][j];
  bool m;
  for (int i = 0; i < 8; ++i) {
    m = true;
    for (int j = 0; j < 8; ++j) m *= (a[i][j] == 'B');
    if (m) s++;
  }
  for (int j = 0; j < 8; ++j) {
    m = true;
    for (int i = 0; i < 8; ++i) m *= (a[i][j] == 'B');
    if (m) s++;
  }
  if (s == 16) s = 8;
  cout << s;
}
