#include <bits/stdc++.h>
using namespace std;
string s[8];
int a[8][8];
int main() {
  for (int i = 0; i < 8; i++) {
    cin >> s[i];
  }
  int ans1 = 0;
  for (int i = 0; i < 8; i++) {
    int u = 0;
    for (int j = 0; j < 8; j++) {
      if (s[i][j] != 'B') u = 1;
    }
    if (u == 0) {
      ans1++;
    }
  }
  if (ans1 == 8) {
    cout << ans1;
    return 0;
  }
  int ans2 = 0;
  for (int i = 0; i < 8; i++) {
    int u = 0;
    for (int j = 0; j < 8; j++) {
      if (s[j][i] != 'B') u = 1;
    }
    if (u == 0) {
      ans2++;
    }
  }
  cout << ans1 + ans2;
  return 0;
}
