/*
#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 = i + o;
n = i + o;
while (n > 9)
{
n -= 10;
}
rows[i] += to_string(n);
if (i < 10 / 2)
{
n = o - i;
while (n < 0)
{
n += 10;
}
}
else
{
n = o - i + 1;
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] += " ";
}
}
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;
cin >> a;
return 0;
}*/
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
using namespace std;
const int SEQUENCE_BITS = 128;
int main()
{
unsigned int k = 0;
cin >> k;
unsigned int subCount = 0;
unsigned int i = 0;
if (k > 100)
{
i = k;
}
bitset<SEQUENCE_BITS> bitSequence(0);
string sequence = "";
while (subCount != k)
{
i++;
bitSequence = bitset<SEQUENCE_BITS>(i);
sequence = to_string(stoull(bitSequence.to_string()));
vector<unsigned int>last(max(sequence.length() * 8, (unsigned int)128), -1);
const unsigned int n = sequence.length();
unsigned int* dp = new unsigned int[n + 1];
dp[0] = 1;
for (unsigned int i = 1; i <= n; i++)
{
dp[i] = 2 * dp[i - 1];
if (last[sequence[i - 1]] != (unsigned int)-1)
{
dp[i] = dp[i] - dp[last[sequence[i - 1]]];
}
last[sequence[i - 1]] = (i - 1);
}
subCount = dp[n] - 1;
}
cout << sequence << "\n";
int a = 0;
cin >> a;
return 0;
}