#include <bits/stdc++.h>
using namespace std;
long long d[64][64][2][2];
long long cc(vector<int> know) {
  memset(d, 0, sizeof(d));
  long long res = 0;
  d[0][((int)know.size()) - 1][0][0] = 1;
  for (int x = 0, y = ((int)know.size()) - 1; x <= y; ++x, --y) {
    for (int d1 = (0), _b(2); d1 < _b; ++d1)
      if (know[x] == -1 || know[x] == d1)
        for (int d2 = (0), _b(2); d2 < _b; ++d2)
          if (know[y] == -1 || know[y] == d2) {
            if (x == y && d1 != d2) continue;
            for (int c0 = (0), _b(2); c0 < _b; ++c0)
              for (int c1 = (0), _b(2); c1 < _b; ++c1) {
                if (c0 == 0 && d1 > d2) continue;
                if (c1 == 0 && d1 > !d2) continue;
                int n0 = c0;
                int n1 = c1;
                if (d1 < d2) n0 = 1;
                if (d1 < !d2) n1 = 1;
                if (x + 1 <= y - 1)
                  d[x + 1][y - 1][n0][n1] += d[x][y][c0][c1];
                else
                  res += d[x][y][c0][c1];
              }
          }
  }
  return res;
}
int main() {
  int n;
  long long k;
  cin >> n >> k;
  vector<int> know(n, -1);
  know[0] = 0;
  ++k;
  if (cc(know) < k)
    cout << -1 << endl;
  else {
    for (int i = 1; i < ((int)know.size()); ++i) {
      know[i] = 0;
      long long p = cc(know);
      if (p < k) {
        k -= p;
        ++know[i];
      }
    }
    for (int i = (0), _b(((int)know.size())); i < _b; ++i) cout << know[i];
    cout << endl;
  }
  return 0;
}
