#include <bits/stdc++.h>
using namespace std;
const int maxe = 1000000;
const int maxn = 11184;
int nprim[maxe];
int pm[maxn + 6], pml;
void init() {
  int i, j, tm, tmp;
  for (i = 4; i < maxe; i += 2) nprim[i] = 1;
  for (i = 3; i < maxe; i += 2) {
    if (nprim[i] == 0) {
      for (j = i << 1; j < maxe; j += i) nprim[j] = 1;
    }
  }
  pml = 0;
  for (i = 13; i < maxe; i += 2) {
    if (nprim[i]) continue;
    tm = i;
    tmp = 0;
    while (tm) {
      tmp = tmp * 10 + tm % 10;
      tm /= 10;
    }
    if (tmp == i) continue;
    if (nprim[tmp] == 0) {
      pm[pml++] = i;
      pm[pml++] = tmp;
      nprim[tmp] = 1;
      nprim[i] = 1;
    }
    if (pml >= maxn) break;
  }
}
int main() {
  int n;
  init();
  sort(pm, pm + pml);
  scanf("%d", &n);
  n--;
  printf("%d\n", pm[n]);
  return 0;
}

### Prompt

Your task is to create 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 maxe = 1000000;
const int maxn = 11184;
int nprim[maxe];
int pm[maxn + 6], pml;
void init() {
  int i, j, tm, tmp;
  for (i = 4; i < maxe; i += 2) nprim[i] = 1;
  for (i = 3; i < maxe; i += 2) {
    if (nprim[i] == 0) {
      for (j = i << 1; j < maxe; j += i) nprim[j] = 1;
    }
  }
  pml = 0;
  for (i = 13; i < maxe; i += 2) {
    if (nprim[i]) continue;
    tm = i;
    tmp = 0;
    while (tm) {
      tmp = tmp * 10 + tm % 10;
      tm /= 10;
    }
    if (tmp == i) continue;
    if (nprim[tmp] == 0) {
      pm[pml++] = i;
      pm[pml++] = tmp;
      nprim[tmp] = 1;
      nprim[i] = 1;
    }
    if (pml >= maxn) break;
  }
}
int main() {
  int n;
  init();
  sort(pm, pm + pml);
  scanf("%d", &n);
  n--;
  printf("%d\n", pm[n]);
  return 0;
}

```