#include <bits/stdc++.h>
using namespace std;
string s;
bool col[9];
int main() {
  int res = 0;
  for (int i = 0, _a = (8); i < _a; ++i) {
    cin >> s;
    vector<int> l;
    for (int j = 0, _a = (int(s.size())); j < _a; ++j)
      if (s[j] == 'B') l.push_back(j);
    if (int(l.size()) < 8)
      for (int j = 0, _a = (int(l.size())); j < _a; ++j) col[l[j]] = 1;
    else
      res++;
  }
  if (res < 8)
    for (int i = 0, _a = (8); i < _a; ++i)
      if (col[i]) res++;
  cout << res;
  return 0;
}
