#include <bits/stdc++.h>
using namespace std;
const int MAXSIZE = 8 + 10;
int main() {
  char c[MAXSIZE][MAXSIZE];
  bool mark[MAXSIZE][MAXSIZE];
  for (int i = 1; i <= 8; i++)
    for (int j = 1; j <= 8; j++) cin >> c[i][j], mark[i][j] = 0;
  int ans = 0;
  bool paint;
  for (int i = 1; i <= 8; i++) {
    paint = true;
    for (int j = 1; j <= 8; j++) paint = paint && (c[i][j] == 'B');
    if (paint) {
      ans++;
      for (int j = 1; j <= 8; j++) mark[i][j] = 1;
    }
  }
  for (int j = 1; j <= 8; j++) {
    paint = false;
    for (int i = 1; i <= 8; i++)
      paint = paint || (!mark[i][j] && c[i][j] == 'B');
    if (paint) ans++;
  }
  cout << ans << endl;
  return 0;
}
