#include <bits/stdc++.h>
using namespace std;
int a, b = 10, ans;
string s;
int main() {
  for (int i = 0; i < 8; i++) {
    cin >> s;
    ans = 0;
    for (int j = 0; j < 8; j++)
      if (s[j] == 'B') ans++;
    if (ans == 8) a++;
    b = min(b, ans);
  }
  if (a == 8)
    puts("8");
  else
    cout << a + b << endl;
  return 0;
}
