#include <bits/stdc++.h>
using namespace std;
int main() {
  int counter = 0, j;
  char arr[9][9];
  for (int i = 0; i < 8; i++) {
    int flag = 0;
    string s;
    cin >> s;
    for (j = 0; j < 8; j++) {
      arr[i][j] = s[j];
      if (s[j] != 'B') flag = 1;
    }
    if (!flag) counter++;
  }
  if (counter != 8)
    for (int i = 0; i < 8; i++) {
      int flag = 0;
      for (j = 0; j < 8; j++) {
        if (arr[j][i] != 'B') flag = 1;
      }
      if (!flag) counter++;
    }
  cout << counter;
  return 0;
}
