#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long R = 7 + 1e9, NUMTESTCASE;
const long long NN = 10 + 1e6;
const double pi = acos(-1.0);
int di[8] = {1, 0, -1, 0, 1, -1, 1, -1}, dj[8] = {0, 1, 0, -1, 1, -1, -1, 1};
int main() {
  string s[9];
  for (int i = (0); i <= (8 - 1); ++i) cin >> s[i];
  int x = 0, y = 0;
  for (int i = (0); i <= (8 - 1); ++i) {
    bool Tot = true;
    for (int j = (0); j <= (8 - 1); ++j) Tot &= (s[i][j] == 'B');
    x += Tot;
    Tot = true;
    for (int j = (0); j <= (8 - 1); ++j) Tot &= (s[j][i] == 'B');
    x += Tot;
  }
  x = x == 16 ? 8 : x;
  cout << x;
  return 0;
}
