$_=<>;s/B/$-+=$'=~y,A,,/ge;print$-