#include <bits/stdc++.h>
using namespace std;
int res[500005], x, n, m;
char p[1000005], s[14];
void GenPrime(int n) {
  for (int i = 2; i <= n; i++) p[i] = 1;
  for (int i = 2; i <= n; i++)
    for (int j = i + i; p[i] && j <= n; j += i) p[j] = 0;
}
int main() {
  GenPrime(1000000);
  for (int i = 2; i <= 1000000; i++) {
    if (!p[i]) continue;
    sprintf(s, "%d", i);
    reverse(s, s + strlen(s));
    sscanf(s, "%d", &x);
    if (p[x] && x != i) res[m++] = i;
  }
  scanf("%d", &n);
  printf("%d\n", res[n - 1]);
  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>
using namespace std;
int res[500005], x, n, m;
char p[1000005], s[14];
void GenPrime(int n) {
  for (int i = 2; i <= n; i++) p[i] = 1;
  for (int i = 2; i <= n; i++)
    for (int j = i + i; p[i] && j <= n; j += i) p[j] = 0;
}
int main() {
  GenPrime(1000000);
  for (int i = 2; i <= 1000000; i++) {
    if (!p[i]) continue;
    sprintf(s, "%d", i);
    reverse(s, s + strlen(s));
    sscanf(s, "%d", &x);
    if (p[x] && x != i) res[m++] = i;
  }
  scanf("%d", &n);
  printf("%d\n", res[n - 1]);
  return 0;
}

```