#include <bits/stdc++.h>
using namespace std;
int t, n;
char a[17][17];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int ans = 0;
  for (int i = 1; i <= 8; ++i)
    for (int j = 1; j <= 8; ++j) cin >> a[i][j];
  for (int i = 1; i <= 8; ++i) {
    int c = 0;
    for (int j = 1; j <= 8; ++j)
      if (a[i][j] == 'B') c++;
    if (c == 8) {
      ans++;
      for (int j = 1; j <= 8; ++j) a[i][j] = 'W';
    }
  }
  for (int i = 1; i <= 8; ++i)
    for (int j = 1; j <= 8; ++j)
      if (a[j][i] == 'B') {
        ans++;
        break;
      }
  cout << ans;
  return 0;
}
