#include <bits/stdc++.h>
char ch;
int fre[30];
const int MAXN = 5000005;
int prime[MAXN], size;
bool mark[MAXN];
void getprime() {
  int i, j;
  size = 0;
  memset(mark, true, sizeof(mark));
  for (i = 2; i < MAXN; i++) {
    if (mark[i]) prime[size++] = i;
    for (j = 0; j < size && i * prime[j] < MAXN; j++) {
      mark[i * prime[j]] = false;
      if (i % prime[j] == 0) break;
    }
  }
}
int test(int id) {
  int i, j;
  i = prime[id];
  j = 0;
  while (i) {
    j = j * 10 + i % 10;
    i /= 10;
  }
  if (j == prime[id]) return 0;
  return mark[j];
}
int main() {
  int n, i, ans = 0;
  scanf("%d", &n);
  getprime();
  for (i = 0; ans < n; i++) {
    ans += test(i);
  }
  printf("%d\n", prime[i - 1]);
  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>
char ch;
int fre[30];
const int MAXN = 5000005;
int prime[MAXN], size;
bool mark[MAXN];
void getprime() {
  int i, j;
  size = 0;
  memset(mark, true, sizeof(mark));
  for (i = 2; i < MAXN; i++) {
    if (mark[i]) prime[size++] = i;
    for (j = 0; j < size && i * prime[j] < MAXN; j++) {
      mark[i * prime[j]] = false;
      if (i % prime[j] == 0) break;
    }
  }
}
int test(int id) {
  int i, j;
  i = prime[id];
  j = 0;
  while (i) {
    j = j * 10 + i % 10;
    i /= 10;
  }
  if (j == prime[id]) return 0;
  return mark[j];
}
int main() {
  int n, i, ans = 0;
  scanf("%d", &n);
  getprime();
  for (i = 0; ans < n; i++) {
    ans += test(i);
  }
  printf("%d\n", prime[i - 1]);
  return 0;
}

```