#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int board[8][8] = {0}, answer(0);
  for (int i(0); i < (8); i++) {
    cin >> s;
    for (int j(0); j < (8); j++) {
      if (s[j] == 'B') {
        board[i][j] = 1;
      } else {
        board[i][j] = 0;
      }
    }
  }
  for (int i(0); i < (8); i++) {
    int l = 1;
    for (int j(0); j < (8); j++) {
      l *= board[i][j];
    }
    if (l == 1) {
      answer++;
    }
  }
  for (int i(0); i < (8); i++) {
    int l = 1;
    for (int j(0); j < (8); j++) {
      l *= board[j][i];
    }
    if (l == 1) {
      answer++;
    }
  }
  if (answer == 16) {
    answer = 8;
  }
  cout << answer;
}
