#include <bits/stdc++.h>
using namespace std;
int b, w, ct;
char c;
int a[8][8];
int main() {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      cin >> c;
      if (c == 'B') {
        b = 1;
        a[i][j] = 1;
      } else {
        w = 1;
        a[i][j] = 0;
      }
    }
  }
  if (w == 0) {
    cout << "8";
    return 0;
  }
  for (int i = 0; i < 8; i++) {
    int k = 0;
    for (int j = 0; j < 8; j++) {
      if (a[i][j] == 0) k = 1;
    }
    if (k == 0) ct++;
  }
  for (int i = 0; i < 8; i++) {
    int k = 0;
    for (int j = 0; j < 8; j++) {
      if (a[j][i] == 0) k = 1;
    }
    if (k == 0) ct++;
  }
  cout << ct;
  return 0;
}
