#include <bits/stdc++.h>
using namespace std;
int tot = 0, sum = 0;
int ans[1000001];
int prime[1000001];
int v[1000001];
int n;
void init() {
  for (int i = 2; i <= 1000000; i++) {
    if (!v[i]) prime[++tot] = i;
    for (int j = 1; j <= tot && prime[j] <= (int)(1000000 / i); j++) {
      v[prime[j] * i] = 1;
      if (i % prime[j] == 0) break;
    }
  }
  for (int j = 1; j <= tot; j++) {
    int tmp = prime[j], vf = tmp;
    int get = 0, top = 0;
    while (tmp) get = get * 10 + (tmp % 10), tmp /= 10;
    if (get != vf && !v[get]) ans[++sum] = vf;
  }
}
int main() {
  init();
  scanf("%d", &n);
  printf("%d\n", ans[n]);
  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 tot = 0, sum = 0;
int ans[1000001];
int prime[1000001];
int v[1000001];
int n;
void init() {
  for (int i = 2; i <= 1000000; i++) {
    if (!v[i]) prime[++tot] = i;
    for (int j = 1; j <= tot && prime[j] <= (int)(1000000 / i); j++) {
      v[prime[j] * i] = 1;
      if (i % prime[j] == 0) break;
    }
  }
  for (int j = 1; j <= tot; j++) {
    int tmp = prime[j], vf = tmp;
    int get = 0, top = 0;
    while (tmp) get = get * 10 + (tmp % 10), tmp /= 10;
    if (get != vf && !v[get]) ans[++sum] = vf;
  }
}
int main() {
  init();
  scanf("%d", &n);
  printf("%d\n", ans[n]);
  return 0;
}

```