#include <bits/stdc++.h>
using namespace std;
int main() {
  char cb[8][8];
  int i, j, cnt = 0;
  for (i = 0; i < 8; i++) scanf("%s", cb[i]);
  for (i = 0; i < 8; i++) {
    int temp = 0;
    for (j = 0; j < 8; j++) {
      if (cb[i][j] == 'B')
        temp++;
      else
        break;
    }
    if (temp == 8) cnt++;
  }
  for (i = 0; i < 8; i++) {
    int temp = 0;
    for (j = 0; j < 8; j++) {
      if (cb[j][i] == 'B')
        temp++;
      else
        break;
    }
    if (temp == 8) cnt++;
  }
  if (cnt == 16) cnt /= 2;
  cout << cnt << endl;
  return 0;
}
