#include <bits/stdc++.h>
using namespace std;
int main() {
  string a[10];
  int sum = 0, flag = 1, flag1 = 1;
  for (int i = 1; i <= 8; i++) cin >> a[i];
  if (a[1][0] == 'W')
    for (int i = 1; i <= 7; i++) {
      if (a[1][i] == 'B') sum++;
      if (a[i + 1][0] == 'B') sum++;
    }
  else {
    for (int i = 1; i <= 8; i++)
      for (int j = 0; j <= 7; j++)
        if (a[i][j] != 'B') {
          flag = 0;
          break;
        }
    if (flag == 1)
      sum = 8;
    else {
      flag = 1;
      for (int i = 1; i <= 8; i++) {
        for (int j = 0; j <= 7; j++) {
          if (a[i][j] != 'B') flag = 0;
          if (a[j + 1][i - 1] != 'B') flag1 = 0;
        }
        if (flag == 1) sum++;
        if (flag1 == 1) sum++;
        flag = 1;
        flag1 = 1;
      }
    }
  }
  cout << sum;
  return 0;
}
