#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const int M = 1000005;
bool is[N];
int prm[M];
int getprm(int n) {
  int i, j, k = 0;
  int s, e = (int)(sqrt(0.0 + n) + 1);
  memset(is, 1, sizeof(is));
  prm[k++] = 2;
  is[0] = is[1] = 0;
  for (i = 4; i < n; i += 2) is[i] = 0;
  for (i = 3; i < e; i += 2)
    if (is[i]) {
      prm[k++] = i;
      for (s = i * 2, j = i * i; j < n; j += s) is[j] = 0;
    }
  for (; i < n; i += 2)
    if (is[i]) prm[k++] = i;
  return k;
}
int flip(int a) {
  int b = 0;
  while (a) {
    b *= 10;
    b += a % 10;
    a /= 10;
  }
  return b;
}
int opt[1000005];
int main() {
  int cntp = getprm(1000001);
  int cnt = 0;
  for (int i = 0; i < cntp; i++) {
    int d = flip(prm[i]);
    if (d != prm[i] && is[d]) {
      opt[cnt++] = prm[i];
    }
  }
  int n;
  scanf("%d", &n);
  printf("%d\n", opt[n - 1]);
  return 0;
}

### Prompt

Generate a cpp solution to 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;
const int N = 1000005;
const int M = 1000005;
bool is[N];
int prm[M];
int getprm(int n) {
  int i, j, k = 0;
  int s, e = (int)(sqrt(0.0 + n) + 1);
  memset(is, 1, sizeof(is));
  prm[k++] = 2;
  is[0] = is[1] = 0;
  for (i = 4; i < n; i += 2) is[i] = 0;
  for (i = 3; i < e; i += 2)
    if (is[i]) {
      prm[k++] = i;
      for (s = i * 2, j = i * i; j < n; j += s) is[j] = 0;
    }
  for (; i < n; i += 2)
    if (is[i]) prm[k++] = i;
  return k;
}
int flip(int a) {
  int b = 0;
  while (a) {
    b *= 10;
    b += a % 10;
    a /= 10;
  }
  return b;
}
int opt[1000005];
int main() {
  int cntp = getprm(1000001);
  int cnt = 0;
  for (int i = 0; i < cntp; i++) {
    int d = flip(prm[i]);
    if (d != prm[i] && is[d]) {
      opt[cnt++] = prm[i];
    }
  }
  int n;
  scanf("%d", &n);
  printf("%d\n", opt[n - 1]);
  return 0;
}

```