#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <set>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <tuple>
using namespace std;
typedef long long LL;
vector<vector<bool>> create(int bits) {
LL total = (LL)1<<bits;
vector<vector<bool>> res(total, vector<bool>(bits));
bool cur = true;
LL switching = total/2;
for (int col = 0; col < bits; col++) {
for (int i = 0; i < total; i++) {
if (i % switching == 0) cur = !cur;
res[i][col] = cur;
}
switching /= 2;
}
return res;
}
bool isEven(vector<bool> & b) {
if (b.size() == 1) return true;
int zeroone = 0;
int onezero = 0;
for (int i = 1; i < b.size(); i++) {
if (b[i-1] == 0 && b[i] == 1) zeroone++;
else if (b[i-1] == 1 && b[i] == 0) onezero++;
}
return zeroone == onezero;
}
int getDiff(vector<bool> & b) { // get diff of "01"s minus "10"s
if (b.size() == 1) return 0;
int zeroone = 0;
int onezero = 0;
for (int i = 1; i < b.size(); i++) {
if (b[i-1] == 0 && b[i] == 1) zeroone++;
else if (b[i-1] == 1 && b[i] == 0) onezero++;
}
return zeroone - onezero;
}
void printres(vector<bool> b1, vector<bool> b2) {
for (bool b : b1) {
cout << (int) b;
}
for (bool b : b2) {
cout << (int) b;
}
}
void printvec(vector<bool> b1) {
for (bool b : b1) {
cout << (int) b;
}
cout << endl;
}
void brute(int n, int k) {
auto v = create(n);
//cout << "qwewqe" << endl;
vector<vector<bool>> asd;
for (auto v1 : v) {
if (isEven(v1)) {
asd.push_back(v1);
}
}
//cout << "asda" << endl;
sort(asd.begin(), asd.end());
printvec(asd[k-1]);
}
int main() {
int n, k;
cin >> n >> k;
if (n <= 10) {
brute(n,k);
return 0;
}
//
//
int bits1 = n/2;
int bits2 = n/2 + n%2;
vector<vector<bool>> r1 = create(bits1);
vector<vector<bool>> r2 = create(bits2);
//for (auto v : r2) printvec(v);
//cout << endl;
map<int, vector<vector<bool>>> startWithOne;
map<int, vector<vector<bool>>> startWithZero;
for (auto & v : r2) {
int diff = getDiff(v);
if (v[0] == 0) {
startWithZero[diff].push_back(v);
} else {
startWithOne[diff].push_back(v);
}
}
// TODO sort values
sort(r1.begin(), r1.end());
//n--; // TODO: ok?
for (auto & v : r1) {
int diff = getDiff(v);
int s = 0;
if (v.back() == 0) {
s += startWithZero[-diff].size();
s += startWithOne[-diff - 1].size();
} else {
s += startWithZero[-diff + 1].size();
s += startWithOne[-diff].size();
}
//printvec(v);
//cout << diff << " " << s << endl;
if (k <= s) {
vector<vector<bool>> temp;
if (v.back() == 0) {
move(startWithZero[-diff].begin(), startWithZero[-diff].end(), back_inserter(temp));
move(startWithOne[-diff - 1].begin(), startWithOne[-diff - 1].end(), back_inserter(temp));
} else {
move(startWithZero[-diff + 1].begin(), startWithZero[-diff + 1].end(), back_inserter(temp));
move(startWithOne[-diff].begin(), startWithOne[-diff].end(), back_inserter(temp));
}
sort(temp.begin(), temp.end());
printres(v, temp[k-1]);
return 0;
} else {
k -= s;
}
}
/*
for (auto & v : r1) {
if (isEven(v)) {
res1.push_back(v);
}
}
for (auto & v : r2) {
if (isEven(v)) {
res2.push_back(v);
}
}
sort(res2.begin(), res2.end());
n--; // TODO ONE INDEXED correct?
int first = n/res2.size();
int second = n % res2.size();
for (auto v : res1) { for (bool b : v) { cout << (int) b; } cout << endl; }
cout << res1.size() << " sizes " << res2.size() << endl;
for (bool b : res1[first]) {
cout << (int) b;
}
cout << endl;
for (bool b : res2[second]) {
cout << (int) b;
}
*/
}