#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

const string c5 = "[encoded data, 27783 characters]";
const string c6 = "[encoded data, 27783 characters]";


bool comp(const string & s, const string & t) 
{
	return (s.length() < t.length()) || (s.length() == t.length() && s < t);
}

int main()
{
	freopen("gold.in", "r", stdin);
	freopen("gold.out", "w", stdout);
    int n;
	cin >> n;
	if (n < 3)
	{
		cout << n - 1;
		return 0;
	}
	
	int si =  c5.length();
	int i = si - 1;
	int cnt = 2;
	string prev1 = "1", prev2 = "0";
	while (cnt < n && i >= 0)
	{
		if (c5[i] != '0' && c6[i] != '0')
		{
			prev1 = c5.substr(i, si - i);
			prev2 = c6.substr(i, si - i);
			if (prev1 < prev2) swap(prev1, prev2);
			cnt += 2;
			i--;
			continue;
		}
		if (c5[i] != '0')
		{
			prev2 = prev1;
			prev1 = c5.substr(i, si - i);
			cnt++, i--;
			continue;
		}
		if (c6[i] != '0')
		{
			prev2 = prev1;
			prev1 = c6.substr(i, si - i);
			cnt++, i--;
			continue;
		}
		i--;
	}
	if (cnt == n) cout << prev1 << endl; else cout << prev2 << endl;
}