#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0, r = 0, c = 0, B = 0;
  char ch[8][8];
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) {
      cin >> ch[i][j];
      if (ch[i][j] == 'B') B++;
    }
  if (B == 0) {
    cout << 0;
    exit(0);
  }
  if (B == 64) {
    cout << 8;
    exit(0);
  }
  int I = 9, J = 9;
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++)
      if (ch[i][j] == 'W') {
        I = i;
        J = j;
      }
  for (int i = 0; i < 8; i++) {
    if (ch[I][i] == 'B') c++;
    if (ch[i][J] == 'B') r++;
  }
  if (B == (r * 8 + c * (8 - r)))
    cout << r + c;
  else
    switch (64 - B) {
      case 0: {
        cout << 8;
        break;
      }
      case 1: {
        cout << 14;
        break;
      }
      case 4: {
        cout << 12;
        break;
      }
      case 9: {
        cout << 10;
        break;
      }
      case 16: {
        cout << 8;
        break;
      }
      case 25: {
        cout << 6;
        break;
      }
      case 36: {
        cout << 4;
        break;
      }
      case 49: {
        cout << 2;
        break;
      }
      case 64: {
        cout << 0;
        break;
      }
    }
}
