#include <bits/stdc++.h>
using namespace std;
int main() {
  string str[8];
  int i, j, k = 0, l, tB = 0;
  for (i = 0; i < 8; i++) cin >> str[i];
  for (i = 0; i < 8; i++) {
    tB = 0;
    for (j = 0; j < 8; j++) {
      if (str[i][j] == 'B') tB++;
    }
    if (tB == 8) k++;
    tB = 0;
    for (j = 0; j < 8; j++) {
      if (str[j][i] == 'B') tB++;
    }
    if (tB == 8) k++;
  }
  if (k == 16)
    cout << "8" << endl;
  else
    cout << k << endl;
  return 0;
}
