import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); sc.close(); // if (n == 1) { // System.out.println(m); // return; // } int p = m; long ans = m; for (int i = 1; i < n; i++) { if (p == 1) { ans += n - i; break; } if (p % 2 == 0) { p = p / 2; } else { p = p / 2 + 1; } ans += p; } System.out.println(ans); } }