#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 50 + 10;
int n;
long long k;
long long countWays(string s) {
  long long dp[MAX_N][2][2];
  bool can[MAX_N][2];
  for (int i = 0; i < n; ++i) {
    can[i][0] = s[i] == '0' || s[i] == '?';
    can[i][1] = s[i] == '1' || s[i] == '?';
  }
  memset(dp, 0, sizeof dp);
  dp[0][1][1] = 1;
  int l, r;
  for (l = 0, r = n - 1; l <= r; ++l, --r)
    for (int s1 = 0; s1 < 2; ++s1) {
      for (int s2 = 0; s2 < 2; ++s2) {
        for (int a = 0; a < 2; ++a)
          if (can[l][a]) {
            for (int b = 0; b < 2; ++b)
              if (can[r][b]) {
                int rb = 1 - b;
                if (s1 && a > b) continue;
                if (s2 && a > rb) continue;
                if (l == r && a != b) continue;
                if (l == 0 && a == 1) continue;
                int ns1 = s1 && (a == b);
                int ns2 = s2 && (a == rb);
                dp[l + 1][ns1][ns2] += dp[l][s1][s2];
              }
          }
      }
    }
  long long ans = dp[l][0][0] + dp[l][0][1] + dp[l][1][0] + dp[l][1][1];
  return ans;
}
int main() {
  cin >> n >> k;
  ++k;
  string s(n, '?');
  long long tot = countWays(s);
  if (tot < k) {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 2; ++j) {
      s[i] = '0' + j;
      long long c = countWays(s);
      if (c >= k) break;
      k -= c;
    }
  }
  cout << s << endl;
  return 0;
}
