module String = struct include String let fold_left f init str = let n = String.length str - 1 in let rec doit i acc = if i > n then acc else doit (i + 1) (f acc str.[i]) in doit 0 init end let () = read_line () |> String.fold_left (fun i c -> if c = 'L' then 2*i else 2*i + 1) 1 |> Printf.printf "%d\n"