inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
S = inp.shift().split('')
cnt = 0
b = []
l = 0
while(S[S.length-1] == 'B') {
    S.pop()
}
for(i=0;i<S.length;i++) {
    if (S[i] == 'B') {
        b.push(i)
    } else {
        l = i
    }
}
for(i=0;i<b.length;i++) {
    cnt += l - b[i] - (b.length - i - 1)
}
console.log(cnt)