#include <bits/stdc++.h>
using namespace std;
int main() {
  string *board = new string[8];
  int filas, columnas;
  for (int i = 0; i < 8; i++) cin >> board[i];
  filas = 0;
  for (int i = 0; i < 8; i++)
    if (board[i].compare(string(8, 'B')) == 0) filas += 1;
  if (filas == 8)
    cout << filas << endl;
  else {
    char *s = new char[8];
    columnas = 0;
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        s[j] = board[j][i];
      }
      s[8] = '\0';
      if (strcmp(s, string(8, 'B').c_str()) == 0) columnas += 1;
    }
    cout << columnas + filas << endl;
  }
  return 0;
}
