#include <bits/stdc++.h>
using namespace std;
int main() {
  char board[8][9];
  for (int i = 0; i < 8; i++) {
    cin >> board[i];
  }
  int row = 0, c = 0;
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (board[i][j] == 'B') c++;
    }
    if (c == 8) row++;
    c = 0;
  }
  int col = 0;
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (board[j][i] == 'B') c++;
    }
    if (c == 8) col++;
    c = 0;
  }
  if (row == 8 && col == 8) {
    cout << 8 << endl;
  } else {
    cout << row + col << endl;
  }
  return 0;
}
