#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans, c, cc, i, j;
  for (i = 0, ans = 0, cc = 0; i < 8; i++) {
    char s[9];
    cin >> s;
    for (j = 0, c = 0; j < 8; j++) c += (s[j] == 'B');
    if (c == 8)
      ans++;
    else
      cc = c;
  }
  if (ans < 8) ans += cc;
  cout << ans << endl;
  return 0;
}
