#include <bits/stdc++.h>
int main() {
  int i, j, count = 0;
  char str[9][9];
  for (i = 0; i < 8; i++) {
    gets(str[i]);
  }
  for (i = 0; i < 8; i++) {
    if (str[i][0] == 'B' && str[i][1] == 'B' && str[i][2] == 'B' &&
        str[i][3] == 'B' && str[i][4] == 'B' && str[i][5] == 'B' &&
        str[i][6] == 'B' && str[i][7] == 'B')
      count++;
  }
  if (count < 8) {
    for (i = 0; i < 8; i++) {
      if (str[0][i] == 'B' && str[1][i] == 'B' && str[2][i] == 'B' &&
          str[3][i] == 'B' && str[4][i] == 'B' && str[5][i] == 'B' &&
          str[6][i] == 'B' && str[7][i] == 'B')
        count++;
    }
  }
  printf("%d\n", count);
  return 0;
}
