#include <bits/stdc++.h>
using namespace std;
int main() {
  int count1 = 0, count2 = 0, temp1 = 0, temp2 = 0;
  char c[8][8];
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      cin >> c[i][j];
      if (c[i][j] == 'B') temp1++;
    }
    if (temp1 == 8) count1++;
    temp1 = 0;
  }
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (c[j][i] == 'B') temp2++;
    }
    if (temp2 == 8) count2++;
    temp2 = 0;
  }
  int count = count1 + count2;
  if (count == 16) count = count / 2;
  cout << count << endl;
  return 0;
}
