#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[8][8];
  int k = 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 n = 0;
    for (int j = 0; j < 8; j++) {
      if (a[i][j] == 'B') n++;
    }
    if (n == 8) k++;
  }
  if (k != 8) {
    for (int i = 0; i < 8; i++) {
      int m = 0;
      for (int j = 0; j < 8; j++) {
        if (a[j][i] == 'B') m++;
      }
      if (m == 8) k++;
    }
  }
  cout << k << endl;
}
