/*
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
int main()
{
string rows[10];
for (int i = 0; i < 10; i++)
{
for (int o = 0; o < 10; o++)
{
int n = 0;
if (i < 10 / 2)
{
n = i + o;
}
else if (i < 9)
{
n = i + o + 1;
}
else
{
n = i + o + 6;
}
while (n > 9)
{
n -= 10;
}
rows[i] += to_string(n);
if (i < 9)
{
n = o - i;
}
else
{
n = o - i;
}
while (n < 0)
{
n += 10;
}
if (n == 0)
{
rows[i] += "A";
}
else if (n == 1)
{
rows[i] += "B";
}
else if (n == 2)
{
rows[i] += "C";
}
else if (n == 3)
{
rows[i] += "D";
}
else if (n == 4)
{
rows[i] += "E";
}
else if (n == 5)
{
rows[i] += "F";
}
else if (n == 6)
{
rows[i] += "G";
}
else if (n == 7)
{
rows[i] += "H";
}
else if (n == 8)
{
rows[i] += "I";
}
else if (n == 9)
{
rows[i] += "J";
}
if (o != 9)
{
rows[i] += " ";
}
}
std::cout << rows[i] << "\n";
}
ofstream myfile;
myfile.open("Eppapeli.txt");
if (myfile.is_open())
{
for (int i = 0; i < 10; i++)
{
if (i != 10 - 1)
{
myfile << rows[i] + "\n";
}
else
{
myfile << rows[i];
}
}
myfile.close();
}
int a;
std::cin >> a;
return 0;
}
}*/
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
using namespace std;
int main()
{
const int MAX_CHAR = 64;
unsigned int subCount = 0;
string bitSeq = "1";
unsigned int k = 0;
std::cin >> k;
if (k == 0)
{
std::cout << "\n";
}
else if (k == 1)
{
std::cout << 0 << "\n";
}
else
{
if (k > 999)
{
unsigned int l = 1;
while (subCount < k)
{
if (l % 2)
{
bitSeq += '0';
}
else
{
bitSeq += '1';
}
l++;
vector<unsigned int>last(MAX_CHAR, -1);
const unsigned int n = bitSeq.length();
unsigned int* dp = new unsigned int[n + 1];
dp[0] = 1;
for (unsigned int o = 1; o <= n; o++)
{
dp[o] = 2 * dp[o - 1];
if (last[bitSeq[o - 1]] != (unsigned int) - 1)
{
dp[o] = dp[o] - dp[last[bitSeq[o - 1]]];
}
last[bitSeq[o - 1]] = (o - 1);
}
vector<unsigned int>().swap(last);
subCount = dp[n] - 1;
dp = 0;
}
l--;
if (bitSeq[l] == '1')
{
l--;
}
while (subCount > k)
{
bitSeq[l] = '1';
vector<unsigned int>last(MAX_CHAR, -1);
const unsigned int n = bitSeq.length();
unsigned int* dp = new unsigned int[n + 1];
dp[0] = 1;
for (unsigned int o = 1; o <= n; o++)
{
dp[o] = 2 * dp[o - 1];
if (last[bitSeq[o - 1]] != (unsigned int) - 1)
{
dp[o] = dp[o] - dp[last[bitSeq[o - 1]]];
}
last[bitSeq[o - 1]] = (o - 1);
}
vector<unsigned int>().swap(last);
subCount = dp[n] - 1;
l -= 2;
}
subCount = 0;
}
unsigned int l = bitSeq.length();
while (subCount != k)
{
for (unsigned int b = l - 1; b >= 0; b--)
{
if (bitSeq[b] != '1')
{
bitSeq[b] = '1';
for (unsigned int c = b + 1; c < l; c++)
{
bitSeq[c] = '0';
}
break;
}
else if (b == 0)
{
bitSeq = "1";
bitSeq += string(l, '0');
l++;
break;
}
}
string reverseBits = bitSeq;
reverse(reverseBits.begin(), reverseBits.end());
reverseBits = reverseBits.substr(reverseBits.find("1", 0));
int b = stoi(bitSeq, nullptr, 2)
int c = stoi(reverseBits, nullptr, 2)
if (c <= b)
{
const unsigned int n = l;
vector<unsigned int>last(MAX_CHAR, -1);
unsigned int* dp = new unsigned int[n + 1];
dp[0] = 1;
for (unsigned int o = 1; o <= n; o++)
{
dp[o] = 2 * dp[o - 1];
if (last[bitSeq[o - 1]] != (unsigned int)-1)
{
dp[o] = dp[o] - dp[last[bitSeq[o - 1]]];
}
last[bitSeq[o - 1]] = (o - 1);
}
vector<unsigned int>().swap(last);
subCount = dp[n] - 1;
}
}
std::cout << bitSeq << "\n";
}
unsigned int a;
std::cin >> a;
return 0;
}