fun main(args: Array<String>) {
    print(readLine()!!.toCharArray()
        .mapIndexed { index, c -> Pair(index, c) }
        .filter { it.second == 'W' }
        .foldRightIndexed(0L) { index, pair, acc -> acc + pair.first - index }
    )
}