#include <bits/stdc++.h>
using namespace std;
int main() {
  char map[8][8];
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) cin >> map[i][j];
  int flag = 0;
  int ans = 0;
  for (int i = 0; i < 8; i++) {
    int count = 0;
    for (int j = 0; j < 8; j++)
      if (map[i][j] == 'B') count++;
    if (count == 8)
      flag++;
    else
      ans = count;
  }
  flag += ans;
  cout << flag << endl;
  return 0;
}
