#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <assert.h>

using namespace std;

const int MAX_NUMBER = (int)1e7;
vector<bool> is_prime(MAX_NUMBER + 10);
vector<int> prime(6.7e5);
int count_prime = 0;

void Eratosphen()
{
	is_prime[0] = is_prime[1] = false;
	for (size_t i = 2; i <= MAX_NUMBER; ++i)
		if (!is_prime[i])
		{
			if ((long long)(i) * (long long)(i) < MAX_NUMBER)
				for (size_t j = i * i; j <= MAX_NUMBER; j += i)
					is_prime[j] = true;
			prime[count_prime++] = i;
		}
}

int main()
{
	freopen("message.in", "r", stdin);
	freopen("message.out", "w", stdout);
	int k;
	cin >> k;
	Eratosphen(); 
	for (size_t i = 0; i < count_prime; i++)
        if (prime[i] * 2 + 1 < MAX_NUMBER)
            if (!is_prime[prime[i] * 2 + 1])
                if (k == 1)
                {
                    cout << prime[i] << endl;
                    return 0;
                }
                else k--;
}
