#include <bits/stdc++.h>
bool map[9][9];
bool nowmap[9][9];
int main() {
  for (int i = 0; i < 8; i++) {
    char buf[10];
    gets(buf);
    for (int j = 0; j < 8; j++) map[i][j] = (buf[j] == 'B');
  }
  int min = 0x3f3f3f;
  for (int mx = 0; mx < (1 << 8); mx++) {
    for (int my = 0; my < (1 << 8); my++) {
      memset(nowmap, 0, sizeof(nowmap));
      int cnt = 0;
      for (int i = 0; i < 8; i++) {
        if (mx & (1 << i)) {
          for (int j = 0; j < 8; j++) nowmap[i][j] = true;
          cnt++;
        }
      }
      for (int i = 0; i < 8; i++) {
        if (my & (1 << i)) {
          for (int j = 0; j < 8; j++) nowmap[j][i] = true;
          cnt++;
        }
      }
      bool same = true;
      for (int i = 0; i < 8; i++)
        for (int j = 0; j < 8; j++)
          if (nowmap[i][j] != map[i][j]) same = false;
      if (same) {
        if (cnt < min) min = cnt;
      }
    }
  }
  printf("%d\n", min);
}
