#include <bits/stdc++.h>
const int MaxN = 1000001;
int prime[MaxN];
void prime_sieve(int x) {
  memset(prime, 0, sizeof prime);
  prime[2] = 1;
  for (int i = 3; i <= x; i += 2) prime[i] = 1;
  for (int i = 3; i * i <= x; i++)
    if (prime[i]) {
      int a = i + i;
      int j = i * i;
      while (j <= x) {
        prime[j] = 0;
        j += a;
      }
    }
}
int main() {
  prime_sieve(1000000);
  int n;
  scanf("%d", &n);
  int count = 0, num;
  for (int i = 13; count < n; i += 2) {
    if (!prime[i]) continue;
    int a = i, v = 0;
    while (a) {
      v = v * 10 + a % 10;
      a /= 10;
    }
    if (i == v || !prime[v]) continue;
    count++;
    num = i;
  }
  printf("%d\n", num);
  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>
const int MaxN = 1000001;
int prime[MaxN];
void prime_sieve(int x) {
  memset(prime, 0, sizeof prime);
  prime[2] = 1;
  for (int i = 3; i <= x; i += 2) prime[i] = 1;
  for (int i = 3; i * i <= x; i++)
    if (prime[i]) {
      int a = i + i;
      int j = i * i;
      while (j <= x) {
        prime[j] = 0;
        j += a;
      }
    }
}
int main() {
  prime_sieve(1000000);
  int n;
  scanf("%d", &n);
  int count = 0, num;
  for (int i = 13; count < n; i += 2) {
    if (!prime[i]) continue;
    int a = i, v = 0;
    while (a) {
      v = v * 10 + a % 10;
      a /= 10;
    }
    if (i == v || !prime[v]) continue;
    count++;
    num = i;
  }
  printf("%d\n", num);
  return 0;
}

```