#include <bits/stdc++.h>
using namespace std;
const long long N = 10;
void read() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
long long dp[N];
void Solve() {
  char ar[9][9];
  for (int i = 1; i <= 8; ++i)
    for (int j = 1; j <= 8; ++j) cin >> ar[i][j];
  long long res = 0, k = 0;
  for (int i = 1; i <= 8; ++i) {
    k = 0;
    for (int j = 1; j <= 8; ++j) k += (ar[i][j] == 'B');
    if (k == 8) res++;
  }
  for (int i = 1; i <= 8; ++i) {
    k = 0;
    for (int j = 1; j <= 8; ++j) k += (ar[j][i] == 'B');
    if (k == 8) res++;
  }
  if (res == 16) res = 8;
  cout << res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long T = 1;
  while (T--) {
    Solve();
    cout << '\n';
  }
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
