#include <bits/stdc++.h>
using namespace std;
int c[8][8];
int d[8][8];
int cnt, now, ans, kol;
char ch;
int main() {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      scanf("%c", &ch);
      if (ch == 'B') {
        cnt++;
        c[i][j] = 1;
      }
    }
    scanf("\n");
  }
  if (cnt == 0) printf("0");
  for (int i = 0; i < 8; i++) {
    now = 0;
    kol = 0;
    for (int j = 0; j < 8; j++) {
      now += c[i][j];
      kol += c[i][j] - d[i][j];
    }
    if (now == 8) {
      ans++;
      cnt -= kol;
      for (int j = 0; j < 8; j++) d[i][j] = 1;
      if (cnt == 0) {
        printf("%d", ans);
        return 0;
      }
    }
  }
  for (int i = 0; i < 8; i++) {
    now = 0;
    kol = 0;
    for (int j = 0; j < 8; j++) {
      now += c[j][i];
      kol += c[j][i] - d[j][i];
    }
    if (now == 8) {
      ans++;
      cnt -= kol;
      for (int j = 0; j < 8; j++) d[j][i] = 1;
      if (cnt == 0) {
        printf("%d", ans);
        return 0;
      }
    }
  }
  return 0;
}
