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 m == 1 { println!("{}", n); 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 mut result = stack.iter().sum::() + (n - stack.len()) * 1; let mut start = m-1; let mut stack = vec![]; while stack.len() < n && start > 1 { stack.push(start); if start & 1 == 1 { start = (start+1)/2; } else { start /= 2; } } result = result.max(stack.iter().sum::() + (n - stack.len()) * 1); println!("{}", result); }