#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[100];
  int ans1 = 0, ans2 = 1000;
  for (int i = 0; i < 8; i++) {
    cin >> s;
    int add = 0;
    for (int j = 0; j < 8; j++) {
      if (s[j] == 'B') add++;
    }
    if (add == 8) ans1++;
    ans2 = min(ans2, add);
  }
  if (ans1 == 8)
    cout << 8 << endl;
  else
    cout << ans1 + ans2 << endl;
  return 0;
}
