#include <bits/stdc++.h>
int prime[5000000];
int main() {
  int a;
  scanf("%d", &a);
  prime[0] = prime[1] = -1;
  for (int i = 2; i < 5000000; i++) {
    if (~prime[i]) {
      prime[i] = 1;
      for (int j = i + i; j < 5000000; j += i) prime[j] = -1;
    }
  }
  int count = 0;
  int at = 10;
  do {
    at++;
    int B = at;
    if (!~prime[B]) continue;
    int C = 0;
    while (B) {
      C *= 10;
      C += B % 10;
      B /= 10;
    }
    if (at == C) continue;
    if (!~prime[C]) continue;
    count++;
  } while (count < a);
  printf("%d\n", at);
}

### Prompt

Construct a cpp code solution to the problem outlined:

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>
int prime[5000000];
int main() {
  int a;
  scanf("%d", &a);
  prime[0] = prime[1] = -1;
  for (int i = 2; i < 5000000; i++) {
    if (~prime[i]) {
      prime[i] = 1;
      for (int j = i + i; j < 5000000; j += i) prime[j] = -1;
    }
  }
  int count = 0;
  int at = 10;
  do {
    at++;
    int B = at;
    if (!~prime[B]) continue;
    int C = 0;
    while (B) {
      C *= 10;
      C += B % 10;
      B /= 10;
    }
    if (at == C) continue;
    if (!~prime[C]) continue;
    count++;
  } while (count < a);
  printf("%d\n", at);
}

```