#include <bits/stdc++.h>
const double Pi = acos(-1.0);
using namespace std;
int main(int argc, char** argv) {
  char board[8][8];
  int strokes = 0;
  bool completion = 0;
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 9; j++) {
      scanf("%c", &board[i][j]);
    }
  }
  for (int j = 0; j < 8; j++) {
    if (board[0][j] == 'B') {
      for (int i = 1; i < 8; i++) {
        if (board[i][j] == 'B') {
          completion = 1;
        } else {
          completion = 0;
          break;
        }
      }
      if (completion == 1) {
        strokes = strokes + 1;
      }
    }
  }
  if (strokes == 8) {
    cout << strokes << endl;
    return 0;
  }
  for (int j = 0; j < 8; j++) {
    if (board[j][0] == 'B') {
      for (int i = 1; i < 8; i++) {
        if (board[j][i] == 'B') {
          completion = 1;
        } else {
          completion = 0;
          break;
        }
      }
      if (completion == 1) {
        strokes = strokes + 1;
      }
    }
  }
  cout << strokes << endl;
  return 0;
}
