#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, k = 0, m, j;
  char chbd[8][8];
  for (n = 0; n < 8; n++) {
    for (i = 0; i < 8; i++) {
      cin >> chbd[n][i];
    }
  }
  for (n = 0; n < 8; ++n) {
    j = 0;
    m = 0;
    for (i = 0; i < 8; ++i) {
      if (chbd[n][i] == 'B') {
        j++;
      }
      if (chbd[i][n] == 'B') {
        m++;
      }
    }
    if (m == 8) {
      ++k;
    }
    if (j == 8) {
      ++k;
    }
  }
  if (k == 16) {
    cout << "8";
  } else
    cout << k;
  return 0;
}
