#include <bits/stdc++.h>
using namespace std;
char Map[8][8];
int rows[8], col[8];
int main() {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      cin >> Map[i][j];
    }
  }
  for (int j = 0; j < 8; j++) {
    int num = 0;
    for (int i = 0; i < 8; i++) {
      if (Map[j][i] == 'B') num++;
    }
    if (num != 8) {
      for (int i = 0; i < 8; i++) {
        if (Map[j][i] == 'B') {
          col[i] = 1;
        }
      }
    } else
      rows[j] = 1;
  }
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (Map[i][j] == 'B' && col[j] == 0) {
        rows[i] = 1;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < 8; i++) {
    ans += (rows[i] + col[i]);
  }
  cout << ans << endl;
}
