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