fn main() { let mut nm = String::new(); std::io::stdin().read_line(&mut nm).ok(); let nm: Vec = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nm[0]; let m = nm[1]; if n <= 60 && (1 << (n-1)) <= m { println!("{}", (1usize << n) - 1); return; } let mut start = m; let mut stack = vec![]; while stack.len() < n && start > 1 { stack.push(start); if start & 1 == 1 { start = (start+1)/2; } else { start /= 2; } } let result = stack.iter().sum::() + (n - stack.len()) * 1; println!("{}", result); }