#include <bits/stdc++.h>
using namespace std;
int main() {
  char abc[100][100];
  int i, j;
  for (i = 0; i <= 7; i++) {
    cin >> abc[i];
  }
  int count = 0;
  for (i = 0; i <= 7; i++) {
    for (j = 0; j <= 7; j++) {
      if (abc[i][j] == 'B') {
        count++;
      }
    }
  }
  if (count == 64) {
    cout << "8" << endl;
  } else {
    count = 0;
    for (i = 0; i <= 7; i++) {
      int scount = 0;
      for (j = 0; j <= 7; j++) {
        if (abc[i][j] == 'B') {
          scount++;
        }
      }
      if (scount == 8) {
        count++;
      }
    }
    for (i = 0; i <= 7; i++) {
      int scount = 0;
      for (j = 0; j <= 7; j++) {
        if (abc[j][i] == 'B') {
          scount++;
        }
      }
      if (scount == 8) {
        count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}
