#include <bits/stdc++.h>
using namespace std;
int is_prime(int x) {
  for (int i = 2; i <= (int)sqrt(x); i++) {
    if (x % i == 0) {
      return 0;
    }
  }
  return 1;
}
int check(int i) {
  int a;
  char s[15];
  sprintf(s, "%d%c", i, '\0');
  reverse(s, s + strlen(s));
  a = atoi(s);
  if (is_prime(a) && a != i) {
    return 1;
  }
  return 0;
}
int main(void) {
  int d;
  int count = 0;
  int i = 1;
  scanf(" %d", &d);
  while (count < d) {
    i++;
    if (is_prime(i) && check(i)) {
      count++;
    }
  }
  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>
using namespace std;
int is_prime(int x) {
  for (int i = 2; i <= (int)sqrt(x); i++) {
    if (x % i == 0) {
      return 0;
    }
  }
  return 1;
}
int check(int i) {
  int a;
  char s[15];
  sprintf(s, "%d%c", i, '\0');
  reverse(s, s + strlen(s));
  a = atoi(s);
  if (is_prime(a) && a != i) {
    return 1;
  }
  return 0;
}
int main(void) {
  int d;
  int count = 0;
  int i = 1;
  scanf(" %d", &d);
  while (count < d) {
    i++;
    if (is_prime(i) && check(i)) {
      count++;
    }
  }
  printf("%d\n", i);
  return 0;
}

```