#include <bits/stdc++.h>
bool isPrime(long input) {
  for (int k = 2; k <= sqrt(input) + 1; k++) {
    if (input % k == 0) {
      return 0;
    }
  }
  return 1;
}
long reverse(long input) {
  long output(0);
  while (input > 0) {
    output = 10 * output + (input % 10);
    input /= 10;
  }
  return output;
}
int main() {
  long d(0);
  scanf("%ld", &d);
  long test(1), count(0);
  while (count < d) {
    ++test;
    if (test != reverse(test) && isPrime(test) && isPrime(reverse(test))) {
      ++count;
    }
  }
  printf("%ld\n", test);
  return 0;
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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>
bool isPrime(long input) {
  for (int k = 2; k <= sqrt(input) + 1; k++) {
    if (input % k == 0) {
      return 0;
    }
  }
  return 1;
}
long reverse(long input) {
  long output(0);
  while (input > 0) {
    output = 10 * output + (input % 10);
    input /= 10;
  }
  return output;
}
int main() {
  long d(0);
  scanf("%ld", &d);
  long test(1), count(0);
  while (count < d) {
    ++test;
    if (test != reverse(test) && isPrime(test) && isPrime(reverse(test))) {
      ++count;
    }
  }
  printf("%ld\n", test);
  return 0;
}

```