#include <bits/stdc++.h>
using namespace std;
const int N = 50;
int n;
long long wys[N][N][2][2], m;
bool visited[N][N][2][2];
int bit[N];
long long f(int l, int r, int rev, int inv) {
  if (l > r) return 1;
  if (visited[l][r][rev][inv]) return wys[l][r][rev][inv];
  visited[l][r][rev][inv] = true;
  long long &val = wys[l][r][rev][inv] = 0;
  for (int u = 0; u < 2; ++u)
    if (bit[l] == -1 || bit[l] == u)
      for (int v = 0; v < 2; ++v)
        if (bit[r] == -1 || bit[r] == v) {
          if ((l != r || u == v) && (rev || u <= v) && (inv || u <= 1 - v)) {
            int tRev = rev || u < v;
            int tInv = inv || u < 1 - v;
            val += f(l + 1, r - 1, tRev, tInv);
          }
        }
  return val;
}
int main() {
  cin >> n >> m;
  memset(bit, -1, sizeof(bit));
  bit[0] = 0;
  m++;
  if (f(0, n - 1, 0, 0) < m) return puts("-1"), 0;
  for (int i = 1; i < n; ++i) {
    memset(visited, 0, sizeof(visited));
    bit[i] = 0;
    long long number = f(0, n - 1, 0, 0);
    if (number < m) {
      m -= number;
      bit[i] = 1;
    }
  }
  for (int i = 0; i < n; ++i) printf("%d", bit[i]);
  puts("");
}
