#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int a[N], n, tot;
long long dp[N][3][3][3][3][3][3], k;
bool ok1[3][3], ok2[3][3];
int wk(int x, int y) {
  if (x < y) return 0;
  if (x > y) return 1;
  return 2;
}
void getF(int *f, int p, int q, int x, int y) {
  f[0] = wk(q, p);
  f[1] = wk(q ^ 1, p);
  f[2] = wk(p, x);
  f[3] = wk(p, q);
  f[4] = wk(p ^ 1, q);
  f[5] = wk(q, y);
}
void work(int x, int f, int &newX, bool left) {
  if (!left) {
    if (f == 0) newX = 0;
    if (f == 1) newX = 1;
    if (f == 2) newX = x;
  } else {
    if (x == 2)
      newX = f;
    else
      newX = x;
  }
}
long long dpit(int i, int X, int Y, int Z, int x, int y, int z) {
  long long &ret = dp[i][X][Y][Z][x][y][z];
  if (~ret) return ret;
  int f[6], b[6], c[6];
  c[0] = X, c[1] = Y, c[2] = Z;
  c[3] = x, c[4] = y, c[5] = z;
  if (i == tot - tot / 2) {
    if (ok1[X][x] && ok1[Y][y] && ok2[Z][z]) return 1;
    return 0;
  }
  ret = 0;
  for (int p = (0); p < (2); p++) {
    if (!i && p == 1) continue;
    for (int q = (0); q < (2); q++) {
      if (i == tot - 1 - i && p != q) continue;
      getF(f, p, q, a[tot - 1 - i], a[i]);
      for (int j = (0); j < (6); j++) work(c[j], f[j], b[j], j < 3);
      bool flag = 0;
      flag = !b[0] || !b[1] || b[2] == 1;
      if (flag) continue;
      ret += dpit(i + 1, b[0], b[1], b[2], b[3], b[4], b[5]);
    }
  }
  return ret;
}
long long solve(long long x) {
  tot = n;
  for (int i = (0); i < (n); i++) a[i] = (x >> i) & 1;
  memset(dp, -1, sizeof(dp));
  return dpit(0, 2, 2, 2, 2, 2, 2) - 1LL;
}
long long check(long long l, long long r) {
  long long ret = -1, mid, tmp;
  while (l <= r) {
    mid = l + r >> 1;
    if ((tmp = solve(mid)) >= k) {
      ret = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  return ret;
}
int main() {
  ok1[1][0] = ok1[1][1] = ok1[1][2] = 1;
  ok1[2][1] = ok1[2][2] = 1;
  ok2[0][0] = ok2[0][1] = ok2[0][2] = 1;
  ok2[2][0] = ok2[2][2] = 1;
  cin >> n >> k;
  long long x = check(1, (1LL << n) - 1);
  if (x == -1)
    puts("-1");
  else {
    for (int i = n - 1; ~i; i--) printf("%d", (x >> i) & 1);
    puts("");
  }
  return 0;
}
