#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
bool prime[1000111];
void SieveOfEratosthenes(int n) {
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) {
        prime[i] = false;
      }
    }
  }
  for (int p = 2; p <= n; p++) {
    if (prime[p]) {
      v.push_back(p);
    }
  }
}
long long R(long long x) {
  long long q[10];
  long long p = log10(x) + 1;
  long long ans = 0;
  long long z = 1;
  for (long long i = 0; i < p - 1; i++) z *= 10;
  for (long long i = 0; i < p; i++) {
    q[i] = x % 10;
    x /= 10;
  }
  for (long long i = 0; i < p; i++) {
    ans += q[i] * z;
    z /= 10;
  }
  return ans;
}
int main() {
  SieveOfEratosthenes(1000000);
  long long n, t = 0;
  scanf("%I64d", &n);
  for (long long i = 5; i < v.size(); i++) {
    long long u = R(v[i]);
    if (prime[u] && u != v[i]) {
      t++;
    }
    if (t == n) {
      printf("%I64d", v[i]);
      return 0;
    }
  }
}

### Prompt

In CPP, your task is to solve 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;
vector<long long> v;
bool prime[1000111];
void SieveOfEratosthenes(int n) {
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) {
        prime[i] = false;
      }
    }
  }
  for (int p = 2; p <= n; p++) {
    if (prime[p]) {
      v.push_back(p);
    }
  }
}
long long R(long long x) {
  long long q[10];
  long long p = log10(x) + 1;
  long long ans = 0;
  long long z = 1;
  for (long long i = 0; i < p - 1; i++) z *= 10;
  for (long long i = 0; i < p; i++) {
    q[i] = x % 10;
    x /= 10;
  }
  for (long long i = 0; i < p; i++) {
    ans += q[i] * z;
    z /= 10;
  }
  return ans;
}
int main() {
  SieveOfEratosthenes(1000000);
  long long n, t = 0;
  scanf("%I64d", &n);
  for (long long i = 5; i < v.size(); i++) {
    long long u = R(v[i]);
    if (prime[u] && u != v[i]) {
      t++;
    }
    if (t == n) {
      printf("%I64d", v[i]);
      return 0;
    }
  }
}

```