#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[8][8];
  int i, j, k;
  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      a[i][j] = getchar();
    }
    getchar();
  }
  int count = 0;
  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      if (a[i][j] != 'B') continue;
      for (k = 0; k < 8; k++) {
        if (a[k][j] != 'B' && a[k][j] != 'J') break;
      }
      if (k == 8) {
        count++;
        for (k = 0; k < 8; k++) a[k][j] = 'J';
      } else {
        count++;
        for (k = 0; k < 8; k++) a[i][k] = 'J';
      }
    }
  }
  cout << count;
  return 0;
}
