#include <bits/stdc++.h>
using namespace std;
int main() {
  string board[8];
  for (int i = 0; i < 8; i++) cin >> board[i];
  int count = 0, flag = 0;
  int num_black = 0;
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (board[i][j] == 'B') num_black += 1;
    }
  }
  if (num_black == 64) {
    count = 8;
    cout << count << endl;
  } else {
    for (int i = 0; i < 8; i++) {
      if (board[i][0] == 'B') {
        flag = 0;
        for (int j = 1; j < 8; j++) {
          if (board[i][j] != 'B') {
            flag = 1;
            break;
          }
        }
        if (flag == 0) count += 1;
      }
    }
    for (int i = 0; i < 8; i++) {
      if (board[0][i] == 'B') {
        flag = 0;
        for (int j = 1; j < 8; j++) {
          if (board[j][i] != 'B') {
            flag = 1;
            break;
          }
        }
        if (flag == 0) count += 1;
      }
    }
    cout << count << endl;
  }
  return 0;
}
