#include <bits/stdc++.h>
using namespace std;
bool np[1010000];
int pr[1010000], pc;
int pp[1010000], ppc;
char tmp[100];
inline int rev(int a) {
  sprintf(tmp, "%d", a);
  int i, j;
  for (i = 0, j = strlen(tmp) - 1; i < j; i++, j--) swap(tmp[i], tmp[j]);
  return atoi(tmp);
}
int main() {
  long long i, j;
  for (i = 2; i <= 1000000; i++)
    if (!np[i]) {
      pr[pc++] = i;
      for (j = i * i; j <= 1000000; j += i) np[j] = 1;
    }
  for (i = 0; i < pc; i++) {
    int k = rev(pr[i]);
    if (pr[i] != k && np[k] == 0) pp[ppc++] = pr[i];
  }
  int a;
  scanf("%d", &a);
  printf("%d\n", pp[a - 1]);
}

### 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>
using namespace std;
bool np[1010000];
int pr[1010000], pc;
int pp[1010000], ppc;
char tmp[100];
inline int rev(int a) {
  sprintf(tmp, "%d", a);
  int i, j;
  for (i = 0, j = strlen(tmp) - 1; i < j; i++, j--) swap(tmp[i], tmp[j]);
  return atoi(tmp);
}
int main() {
  long long i, j;
  for (i = 2; i <= 1000000; i++)
    if (!np[i]) {
      pr[pc++] = i;
      for (j = i * i; j <= 1000000; j += i) np[j] = 1;
    }
  for (i = 0; i < pc; i++) {
    int k = rev(pr[i]);
    if (pr[i] != k && np[k] == 0) pp[ppc++] = pr[i];
  }
  int a;
  scanf("%d", &a);
  printf("%d\n", pp[a - 1]);
}

```