#include <bits/stdc++.h>
int bin[21] = {1};
char s[10][10], s1[10][10];
bool judge() {
  for (int i = 0; i < 8; i++) {
    if (strcmp(s[i], s1[i])) return false;
  }
  return true;
}
int main() {
  int i, j, k, x;
  for (i = 0; i < 8; i++) gets(s[i]);
  for (i = 1; i <= 20; i++) bin[i] = bin[i - 1] << 1;
  int ans = 20, cnt;
  for (i = 0; i < bin[8]; i++) {
    cnt = 0;
    for (k = 0; k < 8; k++) {
      if (bin[k] & i) cnt++;
    }
    if (cnt >= ans) continue;
    for (j = 0; j < bin[8]; j++) {
      int c1 = cnt;
      for (k = 0; k < 8; k++) {
        if (j & bin[k]) c1++;
      }
      if (c1 >= ans) continue;
      for (k = 0; k < 8; k++) {
        for (x = 0; x < 8; x++)
          s1[k][x] = ((bin[k] & i) || (bin[x] & j)) ? 'B' : 'W';
      }
      if (judge()) ans = c1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
