#pragma GCC optimize("O3","unroll-loops")
#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int LIMIT = 180000000;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    freopen("QUYLUAT.INP", "r", stdin);
    freopen("QUYLUAT.OUT", "w", stdout);

    int n;
    cin >> n;

    vector<bool> isPrime(LIMIT + 1, true);
    vector<int> primes;

    isPrime[0] = isPrime[1] = false;

    for (int i = 2; i <= LIMIT; i++){
        if (isPrime[i]) primes.push_back(i);

        for (int p : primes){
            if (1LL * i * p > LIMIT) break;
            isPrime[i * p] = false;
            if (i % p == 0) break;
        }

        if ((int)primes.size() >= n) break;
    }

    ll p = primes[n - 1];
    cout << 1LL * p * p + n;

    return 0;
}
