use std::io::*; use std::str::FromStr; fn main() { exec(read()); } fn exec(i: String) { if i.is_empty() { return println!("{}", 1); } let char_list: Vec = i.chars().collect(); let length = char_list.len(); let start = multiple(length); let end = multiple(length + 1); let last_line_numbers: Vec = (start..end).collect(); let index = get_index(char_list); println!("{}", last_line_numbers[index - 1]); } fn multiple(i: usize) -> i64 { rec_power2(i, 1) } fn rec_power2(i: usize, acc: i64) -> i64 { if i == 0 { return acc; } else { rec_power2(i - 1, acc * 2) } } fn get_index(mut l: Vec) -> usize { let head = l.remove(0); if head == 'L' { rec_get_index(l, 1) } else { rec_get_index(l, 2) } } fn rec_get_index(mut l: Vec, acc: usize) -> usize { if l.is_empty() { return acc; } let head = l.remove(0); if head == 'L' { return rec_get_index(l, (acc * 2) - 1); } else { return rec_get_index(l, acc * 2); } } fn read() -> T { let mut s = String::new(); stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() }