object Main extends App {
  val str = io.StdIn.readLine()
  val cntB = str.count(_ == 'B')
  var before = 0
  for (i <- 0 to str.length() - 1) {
    if (str(i) == 'B') {
      before += i
    }
  }
  var after = 0
  for (i <- str.length() - 1 to str.length() - cntB by -1) {
    after += i
  }
  println(after - before)
}
