#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
bool vis[maxn][2][2];
long long f[maxn][2][2];
bool ans[maxn];
long long K;
int n;
void init() {
  cin >> n >> K;
  K++;
}
int Inv(int p) { return n - 1 - p; }
long long calc(int s, int t, bool rev, bool rev_inv) {
  int tr = Inv(t);
  if (t > tr) return 1;
  if (t == tr) {
    if (t <= s) return !ans[t] || rev_inv;
    return rev_inv ? 2 : 1;
  }
  long long &ret = f[t][rev][rev_inv];
  if (vis[t][rev][rev_inv]) return ret;
  vis[t][rev][rev_inv] = true;
  ret = 0;
  for (int i = 0; i < 2; i++)
    if (t > s || i == ans[t])
      for (int j = 0; j < 2; j++)
        if (tr > s || j == ans[tr])
          if ((rev || i <= j) && (rev_inv || i <= (j ^ 1)))
            ret += calc(s, t + 1, rev || i < j, rev_inv || (i < (j ^ 1)));
  return ret;
}
void work() {
  memset(vis, 0, sizeof(vis));
  if (calc(0, 0, 0, 0) < K) {
    K = -1;
    return;
  }
  ans[0] = 0;
  for (int i = 1; i < n; i++) {
    memset(vis, 0, sizeof(vis));
    ans[i] = 0;
    long long cur = calc(i, 0, 0, 0);
    if (cur < K) {
      K -= cur;
      ans[i] = 1;
    }
  }
}
void print() {
  if (K == -1) {
    printf("-1\n");
    return;
  }
  for (int i = 0; i < n; i++) printf("%d", ans[i] ? 1 : 0);
  printf("\n");
}
int main() {
  init();
  work();
  print();
  return 0;
}
