#include <bits/stdc++.h>
using namespace std;
char M[10][10];
int ans1 = 10, ans2 = 10, ans;
int main() {
  for (int i = 1; i <= 8; i++) {
    for (int j = 1; j <= 8; j++) scanf("%c", &M[i][j]);
    getchar();
  }
  for (int i = 1; i <= 8; i++) {
    int temp = 0;
    for (int j = 1; j <= 8; j++)
      if (M[i][j] == 'B') temp++;
    ans1 = min(ans1, temp);
  }
  for (int j = 1; j <= 8; j++) {
    int temp = 0;
    for (int i = 1; i <= 8; i++)
      if (M[i][j] == 'B') temp++;
    ans2 = min(ans2, temp);
  }
  if (ans1 == 8 && ans2 == 8)
    ans = 8;
  else
    ans = ans1 + ans2;
  cout << ans << endl;
  return 0;
}
