now = 1 gets.chomp.split("").each{|branch| case branch when "L" now *= 2 when "R" now = now * 2 + 1 end } puts now