#include <bits/stdc++.h>
using namespace std;
int main() {
  string p[8], q = "";
  int n = 0, i, j;
  for (i = 0; i < 8; i++) {
    cin >> p[i];
  }
  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      if (q.find(to_string(j)) != -1) continue;
      if (p[i].find('W') == -1) {
        n++;
        break;
      } else if (p[i][j] == 'B') {
        n++;
        q += to_string(j);
      }
    }
  }
  cout << n << endl;
  return 0;
}
