#include <bits/stdc++.h>
using namespace std;
int t[1100005];
int d, i;
int ans = 0;
void down(int r, int c)
{
if (c == d)
ans = r;
if (t[r] == 0)
{
t[r] = 1;
if (c != d)
down(r * 2, c + 1);
}
else
{
t[r] = 0;
if (c != d)
down(r * 2 + 1, c + 1);
}
}
int main()
{
cin >> d >> i;
while (i--)
{
down(1, 1);
}
cout << ans;
return 0;
}