#include <bits/stdc++.h>
using namespace std;
int r(int n) {
  int t = 0;
  while (n > 0) {
    t = 10 * t + n % 10;
    n /= 10;
  }
  return t;
}
bool isprime(int n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if (!(n & 1)) return false;
  for (int i = 3; i * i <= n; i += 2)
    if (n % i == 0) return false;
  return true;
}
int f(int n) {
  int c = 0, i = 1, p;
  while (c < n) {
    if (isprime(i)) {
      if (i != r(i) && isprime(r(i))) {
        c++;
        p = i;
      }
    }
    i++;
  }
  return p;
}
int main() {
  int n;
  scanf("%d", &n);
  printf("%d\n", f(n));
  return 0;
}

### Prompt

Your challenge is to write 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 r(int n) {
  int t = 0;
  while (n > 0) {
    t = 10 * t + n % 10;
    n /= 10;
  }
  return t;
}
bool isprime(int n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if (!(n & 1)) return false;
  for (int i = 3; i * i <= n; i += 2)
    if (n % i == 0) return false;
  return true;
}
int f(int n) {
  int c = 0, i = 1, p;
  while (c < n) {
    if (isprime(i)) {
      if (i != r(i) && isprime(r(i))) {
        c++;
        p = i;
      }
    }
    i++;
  }
  return p;
}
int main() {
  int n;
  scanf("%d", &n);
  printf("%d\n", f(n));
  return 0;
}

```