#include <bits/stdc++.h>
int N, x;
int isit_prime(int);
int main(void) {
  int p = 11;
  int p2 = 0;
  int itr = 0;
  int cnt = 0;
  int rev = 0;
  scanf("%d", &N);
  int skip_val[] = {2, 4, 2, 2, 2, 4, 2, 2, 2, 4, 2, 2, 2, 4, 2, 2};
  while (1) {
    cnt = 16;
    itr = 0;
    while (cnt--) {
      if (isit_prime(p)) {
        p2 = p;
        while (p2 > 0) {
          rev = rev * 10 + (p2 % 10);
          p2 = p2 / 10;
        }
        if ((rev ^ p) && (isit_prime(rev))) {
          x++;
          if (x == N) return printf("%d\n", p), 0;
        }
      }
      rev = 0;
      p = p += skip_val[itr++];
    }
  }
  return 0;
}
int isit_prime(int n) {
  int k = 0;
  if (n == 2 || n == 3) return 1;
  if (n < 2 || n % 2 == 0 || n % 3 == 0) return 0;
  for (k = 5; k * k <= n; k += 6)
    if (n % k == 0 || n % (k + 2) == 0) return 0;
  return 1;
}

### 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>
int N, x;
int isit_prime(int);
int main(void) {
  int p = 11;
  int p2 = 0;
  int itr = 0;
  int cnt = 0;
  int rev = 0;
  scanf("%d", &N);
  int skip_val[] = {2, 4, 2, 2, 2, 4, 2, 2, 2, 4, 2, 2, 2, 4, 2, 2};
  while (1) {
    cnt = 16;
    itr = 0;
    while (cnt--) {
      if (isit_prime(p)) {
        p2 = p;
        while (p2 > 0) {
          rev = rev * 10 + (p2 % 10);
          p2 = p2 / 10;
        }
        if ((rev ^ p) && (isit_prime(rev))) {
          x++;
          if (x == N) return printf("%d\n", p), 0;
        }
      }
      rev = 0;
      p = p += skip_val[itr++];
    }
  }
  return 0;
}
int isit_prime(int n) {
  int k = 0;
  if (n == 2 || n == 3) return 1;
  if (n < 2 || n % 2 == 0 || n % 3 == 0) return 0;
  for (k = 5; k * k <= n; k += 6)
    if (n % k == 0 || n % (k + 2) == 0) return 0;
  return 1;
}

```