package com.supermars.practice;
import java.io.BufferedInputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;
public class 小球下落 {
static Scanner cin = new Scanner(new BufferedInputStream(System.in));
static PrintStream cout = System.out;
final static int MAXD=20;
static int[] s = new int[1<<MAXD];
public static void main(String[] args) {
Arrays.fill(s, 0);
while (cin.hasNext()) {
int D = cin.nextInt();
int I = cin.nextInt();
int k = 0, n = (1 << D) - 1; // n=maxNodeNumber
for (int i = 0; i < I; i++) {
k = 1; // rootNode
while (true) {
s[k] = s[k]==0?1:0;
//System.out.println("i="+i+" "+s[k]);
k = s[k] == 1 ? k * 2 : k * 2 + 1;
if (k > n)
break;
}
}
cout.printf("%d\n",k/2);
}
}
}
import java.io.BufferedInputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;
public class 小球下落 {
static Scanner cin = new Scanner(new BufferedInputStream(System.in));
static PrintStream cout = System.out;
final static int MAXD=20;
static int[] s = new int[1<<MAXD];
public static void main(String[] args) {
Arrays.fill(s, 0);
while (cin.hasNext()) {
int D = cin.nextInt();
int I = cin.nextInt();
int k = 0, n = (1 << D) - 1; // n=maxNodeNumber
for (int i = 0; i < I; i++) {
k = 1; // rootNode
while (true) {
s[k] = s[k]==0?1:0;
//System.out.println("i="+i+" "+s[k]);
k = s[k] == 1 ? k * 2 : k * 2 + 1;
if (k > n)
break;
}
}
cout.printf("%d\n",k/2);
}
}
}