#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const double EPS = 1e-9;
const double PI = 2 * acos(0.);
const int N = 10;
const int dx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
const int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};
char a[N][N];
bool r[N];
int main() {
  int ans = 0;
  for (int i = 0; i < int(8); ++i) {
    for (int j = 0; j < int(8); ++j) scanf("%c", &a[i][j]);
    scanf("\n");
  }
  for (int i = 0; i < int(8); ++i) {
    bool flag = true;
    for (int j = 0; j < int(8); ++j)
      if (a[i][j] != 'B') {
        flag = false;
        break;
      }
    if (flag) {
      r[i] = true;
      ++ans;
    }
  }
  for (int j = 0; j < int(8); ++j) {
    bool flag = false;
    for (int i = 0; i < int(8); ++i)
      if (a[i][j] == 'B' && !r[i]) {
        flag = true;
        break;
      }
    if (flag) ++ans;
  }
  cout << ans << endl;
  return 0;
}
