#include <bits/stdc++.h>
using namespace std;
string s[8];
int main() {
  int result = 0;
  for (int i = 0; i < 8; i++) cin >> s[i];
  for (int x = 0; x < 8; x++) {
    bool ok = true;
    for (int i = 0; i < 8; i++)
      if (s[x][i] != 'B') {
        ok = false;
        break;
      }
    if (ok) result++;
  }
  for (int x = 0; x < 8; x++) {
    bool ok = true;
    for (int i = 0; i < 8; i++)
      if (s[i][x] != 'B') {
        ok = false;
        break;
      }
    if (ok) result++;
  }
  if (result == 16) result = 8;
  printf("%d\n", result);
}
