#include <bits/stdc++.h>
using namespace std;
int main() {
  char mp[10][10];
  int i, j, ans = 0;
  for (i = 0; i < 8; ++i) scanf("%s", mp[i]);
  for (i = 0; i < 8; ++i) {
    for (j = 0; j < 8; ++j)
      if (mp[j][i] != 'B') break;
    if (j == 8) ++ans;
  }
  if (ans < 8) {
    for (i = 0; i < 8; ++i) {
      for (j = 0; j < 8; ++j)
        if (mp[i][j] != 'B') break;
      if (j == 8) ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}
