#include <bits/stdc++.h>
char f[2000000];
int func(int n) {
  int i, j, k = 0;
  while (n != 0) {
    k *= 10;
    k += n % 10;
    n /= 10;
  }
  return k;
}
int main() {
  int i, j, n, k, a;
  memset(f, 0, sizeof(f));
  scanf("%d", &n);
  for (i = 2; i < 2000000; i++) {
    if (f[i] == 0) {
      for (j = 2; i * j < 2000000; j++) f[i * j] = 1;
    }
  }
  k = 0;
  for (i = 2;; i++) {
    if (f[i] == 0 && i != func(i) && f[func(i)] == 0) k++;
    if (k == n) break;
  }
  printf("%d\n", i);
  return 0;
}

### Prompt

Please formulate 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 f[2000000];
int func(int n) {
  int i, j, k = 0;
  while (n != 0) {
    k *= 10;
    k += n % 10;
    n /= 10;
  }
  return k;
}
int main() {
  int i, j, n, k, a;
  memset(f, 0, sizeof(f));
  scanf("%d", &n);
  for (i = 2; i < 2000000; i++) {
    if (f[i] == 0) {
      for (j = 2; i * j < 2000000; j++) f[i * j] = 1;
    }
  }
  k = 0;
  for (i = 2;; i++) {
    if (f[i] == 0 && i != func(i) && f[func(i)] == 0) k++;
    if (k == n) break;
  }
  printf("%d\n", i);
  return 0;
}

```