#include <bits/stdc++.h>
bool isPrime[1000000];
int prime[1000000], plen = 0;
void Primes() {
  int i, j;
  memset(isPrime, 1, sizeof(isPrime));
  for (i = 2; i < 1000000; i++) {
    if (isPrime[i]) prime[plen++] = i;
    for (j = 0; j < plen && i * prime[j] < 1000000; j++) {
      isPrime[i * prime[j]] = false;
      if (!(i % prime[j])) break;
    }
  }
}
bool is(int n) {
  int m = 0, p = n;
  while (n) {
    m = 10 * m + n % 10;
    n /= 10;
  }
  if (m != p && isPrime[m]) return 1;
  return 0;
}
int main() {
  Primes();
  int n, i, j = 4, p;
  scanf("%d", &n);
  for (i = 0; i < n;) {
    if (is(prime[j])) i++, p = j;
    j++;
  }
  printf("%d\n", prime[p]);
  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>
bool isPrime[1000000];
int prime[1000000], plen = 0;
void Primes() {
  int i, j;
  memset(isPrime, 1, sizeof(isPrime));
  for (i = 2; i < 1000000; i++) {
    if (isPrime[i]) prime[plen++] = i;
    for (j = 0; j < plen && i * prime[j] < 1000000; j++) {
      isPrime[i * prime[j]] = false;
      if (!(i % prime[j])) break;
    }
  }
}
bool is(int n) {
  int m = 0, p = n;
  while (n) {
    m = 10 * m + n % 10;
    n /= 10;
  }
  if (m != p && isPrime[m]) return 1;
  return 0;
}
int main() {
  Primes();
  int n, i, j = 4, p;
  scanf("%d", &n);
  for (i = 0; i < n;) {
    if (is(prime[j])) i++, p = j;
    j++;
  }
  printf("%d\n", prime[p]);
  return 0;
}

```