#include <bits/stdc++.h>
using namespace std;
int n;
long long K;
long long f[55][8];
long long rec(string s, int low, int high, int mask) {
  if (low > high) return 1;
  long long &ans = f[low][mask];
  if (ans >= 0) return ans;
  ans = 0;
  for (int a = 0; a < 2; a++)
    for (int b = 0; b < 2; b++) {
      if (low == high && a != b) continue;
      if (low < s.size() && s[low] != a) continue;
      if (high < s.size() && s[high] != b) continue;
      pair<int, int> orig = make_pair(a, b);
      int _mask = mask;
      pair<int, int> rev = make_pair(b, a);
      if (!(mask & 1) && orig > rev) continue;
      if (orig < rev) _mask |= 1;
      pair<int, int> color = make_pair(a ^ 1, b ^ 1);
      if (!(mask & 2) && orig > color) continue;
      if (orig < color) _mask |= 2;
      pair<int, int> both = make_pair(color.second, color.first);
      if (!(mask & 4) && orig > both) continue;
      if (orig < both) _mask |= 4;
      ans += rec(s, low + 1, high - 1, _mask);
    }
  return ans;
}
long long countNumber(string s) {
  memset(f, -1, sizeof(f));
  return rec(s, 0, n - 1, 0);
}
int main() {
  cin >> n >> K;
  K++;
  if (countNumber("") < K) {
    printf("-1\n");
    return 0;
  }
  char zero = 0, one = 1;
  string ret = "";
  for (int i = 0; i < n; i++) {
    string tmp = ret;
    tmp += zero;
    long long add = countNumber(tmp);
    if (add < K) {
      K -= add;
      tmp[tmp.size() - 1] = one;
    }
    ret = tmp;
  }
  for (int i = 0; i < n; i++) ret[i] += '0';
  cout << ret << endl;
}
