let id x = x

let split_string ?(pattern="") = Str.split @@ Str.regexp pattern

let ss = List.rev @@ split_string @@ Scanf.scanf "%s\n" id

let () =
  let b_cnt = List.length @@ List.filter (fun s -> s = "B") ss in
  let sum = ss |> List.mapi (fun i s -> if s = "B" then i else 0) |> List.fold_left (+) 0 in
  print_int (sum - (b_cnt * (b_cnt - 1) / 2));
  print_newline ()