#include <bits/stdc++.h>
using namespace std;
int main() {
  char ch[8][8];
  int k = 0, m = 0, l = 0;
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) cin >> ch[i][j];
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (ch[i][j] == 'B') k++;
      if (ch[j][i] == 'B') m++;
    }
    if (k == 8) l++;
    if (m == 8) l++;
    k = 0;
    m = 0;
  }
  if (l < 16)
    cout << l << endl;
  else
    cout << 8 << endl;
  return 0;
}
