#include <bits/stdc++.h>
using namespace std;
int const Nprimes = 10;
int primes[Nprimes] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
int Prost(int i) {
  int k;
  if (i == 13 || i == 17) return 1;
  for (k = 0; k < Nprimes; k++)
    if (i % primes[k] == 0) return 0;
  for (k = primes[Nprimes - 1]; k <= sqrt(i); k += 2)
    if (i % k == 0) return 0;
  return 1;
}
int main() {
  int i, a, b, n, nz, zi;
  int const NZ = 2;
  int ZPr[NZ] = {13, 17};
  cin >> n;
  if (n <= NZ)
    i = ZPr[n - 1];
  else {
    nz = NZ;
    for (i = primes[Nprimes - 1] + 2;; i += 2) {
      if (Prost(i) == 1) {
        a = i;
        zi = 0;
        while (a > 0) {
          zi = zi * 10 + a % 10;
          a /= 10;
        }
        if (Prost(zi) == 1)
          if (zi != i) {
            nz++;
            if (nz == n) break;
          }
      }
    }
  }
  cout << i << endl;
  return 0;
}

### Prompt

Create a solution in Cpp for 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;
int const Nprimes = 10;
int primes[Nprimes] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
int Prost(int i) {
  int k;
  if (i == 13 || i == 17) return 1;
  for (k = 0; k < Nprimes; k++)
    if (i % primes[k] == 0) return 0;
  for (k = primes[Nprimes - 1]; k <= sqrt(i); k += 2)
    if (i % k == 0) return 0;
  return 1;
}
int main() {
  int i, a, b, n, nz, zi;
  int const NZ = 2;
  int ZPr[NZ] = {13, 17};
  cin >> n;
  if (n <= NZ)
    i = ZPr[n - 1];
  else {
    nz = NZ;
    for (i = primes[Nprimes - 1] + 2;; i += 2) {
      if (Prost(i) == 1) {
        a = i;
        zi = 0;
        while (a > 0) {
          zi = zi * 10 + a % 10;
          a /= 10;
        }
        if (Prost(zi) == 1)
          if (zi != i) {
            nz++;
            if (nz == n) break;
          }
      }
    }
  }
  cout << i << endl;
  return 0;
}

```