#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000;
int tot, cnt;
int p[maxn], a[maxn];
bool mk[maxn];
int gao(int x) {
  int ret = 0;
  while (x) {
    ret = ret * 10 + x % 10;
    x /= 10;
  }
  return ret;
}
void init() {
  int i, j;
  tot = cnt = 0;
  for (i = 2; i < maxn; i++)
    if (!mk[i]) {
      p[tot++] = i;
      for (j = i * 2; j < maxn; j += i) mk[j] = true;
    }
  for (i = 0; i < tot; i++) {
    int t = gao(p[i]);
    if (t != p[i] && !mk[t]) a[cnt++] = t;
  }
  sort(a, a + cnt);
}
int main() {
  init();
  int n;
  scanf("%d", &n);
  printf("%d\n", a[n - 1]);
  return 0;
}

### 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;
const int maxn = 1000000;
int tot, cnt;
int p[maxn], a[maxn];
bool mk[maxn];
int gao(int x) {
  int ret = 0;
  while (x) {
    ret = ret * 10 + x % 10;
    x /= 10;
  }
  return ret;
}
void init() {
  int i, j;
  tot = cnt = 0;
  for (i = 2; i < maxn; i++)
    if (!mk[i]) {
      p[tot++] = i;
      for (j = i * 2; j < maxn; j += i) mk[j] = true;
    }
  for (i = 0; i < tot; i++) {
    int t = gao(p[i]);
    if (t != p[i] && !mk[t]) a[cnt++] = t;
  }
  sort(a, a + cnt);
}
int main() {
  init();
  int n;
  scanf("%d", &n);
  printf("%d\n", a[n - 1]);
  return 0;
}

```