#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long MOD = 1e9 + 7;
long double EPS = 1e-12;
const long long INF32 = 0x3F3F3F3F;
const long long INF = 0x3F3F3F3F3F3F3F3F;
const long long crng = rng();
set<long long> prime;
vector<long long> comp;
bool isp[(long long)1e7 + 6];
void sieve(long long n = 1e7 + 5) {
  memset(isp, true, sizeof(isp));
  isp[0] = isp[1] = false;
  for (long long j = 4; j <= n; j += 2) isp[j] = false;
  for (long long i = 3; i * i <= n; i += 2) {
    if (!isp[i]) continue;
    for (long long j = i * i; j <= n; j += i) isp[j] = false;
  }
  prime.insert(2);
  for (long long i = 3; i <= n; i += 2) {
    if (isp[i])
      prime.insert(i);
    else
      comp.push_back(i);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  {
    sieve(1e6);
    vector<long long> ans;
    for (auto i : prime) {
      string s = to_string(i);
      reverse((s).begin(), (s).end());
      long long n = stoll(s);
      if (n != i && prime.find(n) != prime.end()) ans.push_back(i);
    }
    long long w;
    cin >> w;
    cout << ans[w - 1] << '\n';
  }
}

### Prompt

Please formulate a Cpp solution to the following problem:

qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. oekh jqia yi je vydt jxu djx ucyhf.

Input

jxu ydfkj sediyiji ev q iydwbu ydjuwuh d (1 ≤ d ≤ 11184) — jxu edu-rqiut ydtun ev jxu ucyhf je vydt.

Output

ekjfkj q iydwbu dkcruh.

Examples

Input

1


Output

13

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long MOD = 1e9 + 7;
long double EPS = 1e-12;
const long long INF32 = 0x3F3F3F3F;
const long long INF = 0x3F3F3F3F3F3F3F3F;
const long long crng = rng();
set<long long> prime;
vector<long long> comp;
bool isp[(long long)1e7 + 6];
void sieve(long long n = 1e7 + 5) {
  memset(isp, true, sizeof(isp));
  isp[0] = isp[1] = false;
  for (long long j = 4; j <= n; j += 2) isp[j] = false;
  for (long long i = 3; i * i <= n; i += 2) {
    if (!isp[i]) continue;
    for (long long j = i * i; j <= n; j += i) isp[j] = false;
  }
  prime.insert(2);
  for (long long i = 3; i <= n; i += 2) {
    if (isp[i])
      prime.insert(i);
    else
      comp.push_back(i);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  {
    sieve(1e6);
    vector<long long> ans;
    for (auto i : prime) {
      string s = to_string(i);
      reverse((s).begin(), (s).end());
      long long n = stoll(s);
      if (n != i && prime.find(n) != prime.end()) ans.push_back(i);
    }
    long long w;
    cin >> w;
    cout << ans[w - 1] << '\n';
  }
}

```