#include <bits/stdc++.h>
using namespace std;
char ma[8][8];
bool all_black() {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (ma[i][j] != 'B') return false;
    }
  }
  return true;
}
int black_ro() {
  int counbr = 0;
  for (int i = 0; i < 8; i++) {
    bool all_black = true;
    for (int j = 0; j < 8; j++) {
      if (ma[i][j] != 'B') all_black = false;
    }
    if (all_black) counbr += 1;
  }
  return counbr;
}
int black_col() {
  int counbc = 0;
  for (int j = 0; j < 8; j++) {
    bool all_black = true;
    for (int i = 0; i < 8; i++) {
      if (ma[i][j] != 'B') all_black = false;
    }
    if (all_black == true) counbc += 1;
  }
  return counbc;
}
int main() {
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) cin >> ma[i][j];
  if (all_black())
    cout << "8\n";
  else
    cout << black_ro() + black_col() << "\n";
  return 0;
}
