#include <bits/stdc++.h>
using namespace std;
int main(void) {
  bool chk;
  int i, j, cnth = 0, cntv = 0;
  string a;
  int arr[8][8];
  for (i = 0; i < 8; i++) {
    cin >> a;
    for (j = 0; j < 8; j++) {
      if (a[j] == 'W') {
        arr[i][j] = 0;
      } else if (a[j] == 'B') {
        arr[i][j] = 1;
      }
    }
  }
  cnth = 0;
  for (i = 0; i < 8; i++) {
    if (arr[i][0] == 1) {
      chk = true;
      for (j = 0; j < 8; j++) {
        if (arr[i][j] != 1) {
          chk = false;
          break;
        }
      }
      if (chk) {
        cnth++;
      }
    }
  }
  if (cnth == 8) {
    printf("8\n");
    return 0;
  }
  cntv = 0;
  for (i = 0; i < 8; i++) {
    if (arr[0][i] == 1) {
      chk = true;
      for (j = 0; j < 8; j++) {
        if (arr[j][i] != 1) {
          chk = false;
          break;
        }
      }
      if (chk) {
        cntv++;
      }
    }
  }
  printf("%d\n", cnth + cntv);
  return 0;
}
