#include <bits/stdc++.h>
using namespace std;
template <class T>
inline string itos(T n) {
  return (n) < 0    ? "-" + itos(-(n))
         : (n) < 10 ? (string)("") + (char)('0' + (n))
                    : itos((n) / 10) + itos((n) % 10);
}
int a[8][8], b[8][8];
int main(void) {
  int i, j, x, y;
  bool ok = true;
  for ((i) = 0; (i) < (int)(8); (i)++) {
    string s;
    cin >> s;
    for ((j) = 0; (j) < (int)(8); (j)++)
      if (s[j] == 'B')
        a[i][j] = 1;
      else
        ok = false;
  }
  if (ok) {
    cout << "8" << endl;
    return 0;
  }
  int ans;
  for ((i) = 0; (i) < (int)((1 << 8)); (i)++)
    for ((j) = 0; (j) < (int)((1 << 8)); (j)++) {
      for ((x) = 0; (x) < (int)(8); (x)++)
        for ((y) = 0; (y) < (int)(8); (y)++)
          if ((i & (1 << x)) || (j & (1 << y)))
            b[x][y] = 1;
          else
            b[x][y] = 0;
      bool flag = true;
      for ((x) = 0; (x) < (int)(8); (x)++)
        for ((y) = 0; (y) < (int)(8); (y)++)
          if (a[x][y] != b[x][y]) flag = false;
      if (flag) {
        ans = __builtin_popcount(i) + __builtin_popcount(j);
        cout << ans << endl;
        return 0;
      }
    }
  return 0;
}
