package main
import (
"bufio"
"fmt"
"math/bits"
"os"
)
func main() {
in := bufio.NewReader(os.Stdin)
board := make([]string, 8)
for i := 0; i < 8; i++ {
fmt.Fscan(in, &board[i])
}
ans := 100
for r := 0; r < 1<<8; r++ {
for c := 0; c < 1<<8; c++ {
ok := true
for i := 0; i < 8 && ok; i++ {
for j := 0; j < 8; j++ {
black := ((r>>i)&1) == 1 || ((c>>j)&1) == 1
if black != (board[i][j] == 'B') {
ok = false
break
}
}
}
if ok {
cnt := bits.OnesCount(uint(r)) + bits.OnesCount(uint(c))
if cnt < ans {
ans = cnt
}
}
}
}
fmt.Println(ans)
}