#include <bits/stdc++.h>
using namespace std;
int main() {
string s[8];
int total=0;
int p=-1;
for(int i=0 ; i<8 ; i++) {
cin >> s[i];
if(s[i]=="BBBBBBBB")total++;
else p=i;
}
if(total!=8){
for(int i=0 ; i<8 ; i++){
if(s[p][i]=='B')total++;
}
}
cout << total;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCXN0cmluZyBzWzhdOwoJaW50IHRvdGFsPTA7CglpbnQgcD0tMTsKCWZvcihpbnQgaT0wIDsgaTw4IDsgaSsrKSB7CgkJY2luID4+IHNbaV07CgkJaWYoc1tpXT09IkJCQkJCQkJCIil0b3RhbCsrOwoJCWVsc2UgcD1pOwoJCQoJfQoJaWYodG90YWwhPTgpewoJZm9yKGludCBpPTAgOyBpPDggOyBpKyspewoJCWlmKHNbcF1baV09PSdCJyl0b3RhbCsrOwoJfQoJfQoJY291dCA8PCB0b3RhbDsKCXJldHVybiAwOwp9