use std::collections::VecDeque; 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; } if n == 1 { println!("{}", m); return; } let mut deque = VecDeque::new(); deque.push_back((3usize, 2usize, 2usize)); let mut cands = vec![]; while let Some((summary, cnt, last)) = deque.pop_front() { if cnt == n { cands.push(summary); continue; } let inserted = last * 2 - 1 > m; if last * 2 <= m { deque.push_back((summary+last*2, cnt+1, last*2)); } else if !inserted { cands.push(summary + (n - cnt)); } if last * 2 - 1 <= m { deque.push_back((summary + last*2-1, cnt+1, last*2-1)); } else { cands.push(summary + (n - cnt)); } } println!("{}", cands.iter().max().unwrap()); }