#include <iostream>
#include <cstdio>
#include <cmath>
#define LL unsigned long long
using namespace std;
__int128 k;
int n;
__int128 fastpow(int x)
{
__int128 ans=1, a=2;
while (x)
{
if (x&1) ans*=a;
a*=a;
x>>=1;
}
return ans;
}
void gray(int l, __int128 f)
{
if (l==0) return;
__int128 t=fastpow(l);
t-=f-1;
__int128 tt=fastpow(l-1);
if (f>tt)
{
cout << 1;
gray(l-1, t);
}
else
{
cout << 0;
gray(l-1, f);
}
}
int main ()
{
scanf("%d %lld", &n, &k);
gray(n, k+1);
return 0;
}