
object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  val str = readLine.trim.toCharArray.map{_ == 'B'}
  val count = str.map{if (_) 1 else 0: Long}
  for (i ← 1 until count.length){
    count(i) += count(i - 1)
  }
  println(
    str.indices.map{i ⇒
      if (!str(i)) count(i)
      else 0
    }.sum
  )
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
