#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> a(8);
  bool used[8][8];
  memset(used, 0, sizeof(used));
  for (int i = 0; i < (int)8; i++) cin >> a[i];
  int res = 0;
  for (int i = 0; i < (int)8; i++) {
    if (!used[0][i] && a[0][i] == 'B') {
      used[0][i] = true;
      int col = 0;
      for (int j = 0; j < (int)8; j++) {
        if (a[j][i] == 'B') {
          col++;
          used[j][i] = true;
        }
      }
      if (col == 8)
        res++;
      else {
        for (int j = 0; j < (int)8; j++) used[j][i] = false;
      }
    }
  }
  for (int i = 0; i < (int)8; i++) {
    if (a[i][0] == 'B') {
      used[i][0] = true;
      int col = 0;
      int c = 0;
      for (int j = 0; j < (int)8; j++) {
        if (!used[i][j]) c++;
        if (a[i][j] == 'B') {
          col++;
          used[i][j] = true;
        }
      }
      if (col == 8 && c != 8 && c != 0) {
        res++;
      }
    }
  }
  cout << res;
  return 0;
}
