#include <bits/stdc++.h>
using namespace std;
int main() {
  int c = 0, ii = 1;
  string a[9];
  for (int i = 1; i <= 8; i++) {
    getline(cin, a[i]);
    if (a[i] == "BBBBBBBB") c++;
  }
  if (c == 8) {
    cout << c;
    return 0;
  }
  for (int j = 0; j < 8; j++)
    if (a[ii][j] == a[ii + 1][j] && a[ii][j] == a[ii + 2][j] &&
        a[ii][j] == a[ii + 3][j] && a[ii][j] == a[ii + 4][j] &&
        a[ii][j] == a[ii + 5][j] && a[ii][j] == a[ii + 6][j] &&
        a[ii][j] == a[ii + 7][j] && a[ii][j] == 'B')
      c++;
  cout << c;
  return 0;
}
