#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, t = 0, c = 0, co = 0, m = 0;
  char a[9][9];
  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      cin >> a[i][j];
    }
  }
  for (i = 0; i < 8; i++) {
    c = 0;
    co = 0;
    for (j = 0; j < 8; j++) {
      if (a[j][i] == 'B') {
        c++;
        a[j][i] = 0;
      } else
        co++;
    }
    if (c == 8)
      t++;
    else if (co > m)
      m = c;
  }
  for (i = 1; i < 8; i++) {
    if (a[i][0] == 'B') t++;
  }
  cout << t + m;
}
