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 < 32 && 1 << (n - 1) < m) { long ans = 0; for (int i = 0; i < n; i++) { ans += 1 << i; } System.out.println(ans); } else { 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); } } }