#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[8][8];
  int count = 0;
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) cin >> a[i][j];
  for (int i = 0; i < 8; i++) {
    int temp = 0;
    int temp2 = 0;
    for (int j = 0; j < 8; j++) {
      if (a[i][j] == 'B') temp++;
      if (a[j][i] == 'B') temp2++;
    }
    if (temp == 8) count++;
    if (temp2 == 8) count++;
  }
  if (count == 16) count = 8;
  cout << count << endl;
  return 0;
}
