#include <bits/stdc++.h>
int main() {
  static char board[8][9];
  int i, j, isblack, k;
  for (i = 0; i < 8; i++) scanf("%s", board[i]);
  k = 0;
  for (i = 0; i < 8; i++) {
    isblack = 1;
    for (j = 0; j < 8; j++)
      if (board[i][j] != 'B') {
        isblack = 0;
        break;
      }
    if (isblack) k++;
  }
  for (j = 0; j < 8; j++) {
    isblack = 1;
    for (i = 0; i < 8; i++)
      if (board[i][j] != 'B') {
        isblack = 0;
        break;
      }
    if (isblack) k++;
  }
  printf("%d\n", k == 16 ? 8 : k);
  return 0;
}
