#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let v = read_vec::(); let (mut n, m) = (v[0], v[1]); let mut ans = 0; let mut cur = 1i64; for _ in 0..n { ans += cur; cur *= 2; if cur > m { break; } } if cur <= m { println!("{}", ans); } let mut ans = 0; let mut cur = m; while cur > 1 { ans += cur; cur = (cur + 1) / 2; n -= 1; if n == 0 { break; } } println!("{}", ans + n); } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }