#include <bits/stdc++.h>
const int N = 1000000 + 5;
int prime[N], np;
bool notprime[N];
inline void pc() {
  notprime[1] = true;
  for (int i = 2; i < N; ++i) {
    if (!notprime[i]) prime[++np] = i;
    for (int j = 1, k; j <= np && (k = i * prime[j]) < N; ++j) {
      notprime[k] = true;
      if (i % prime[j] == 0) break;
    }
  }
}
inline long long rv(int a2) {
  long long a2R = 0;
  while (a2) {
    a2R = a2R * 10 + a2 % 10;
    a2 /= 10;
  }
  return a2R;
}
int main() {
  pc();
  int n;
  scanf("%d", &n);
  for (int i = 1, cnt = 0; i <= np; ++i) {
    if (rv(prime[i]) != prime[i] && !notprime[rv(prime[i])]) {
      ++cnt;
      if (cnt == n) {
        printf("%d\n", prime[i]);
        return 0;
      }
    }
  }
  throw 13332333;
}

### Prompt

In CPP, your task is to solve 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>
const int N = 1000000 + 5;
int prime[N], np;
bool notprime[N];
inline void pc() {
  notprime[1] = true;
  for (int i = 2; i < N; ++i) {
    if (!notprime[i]) prime[++np] = i;
    for (int j = 1, k; j <= np && (k = i * prime[j]) < N; ++j) {
      notprime[k] = true;
      if (i % prime[j] == 0) break;
    }
  }
}
inline long long rv(int a2) {
  long long a2R = 0;
  while (a2) {
    a2R = a2R * 10 + a2 % 10;
    a2 /= 10;
  }
  return a2R;
}
int main() {
  pc();
  int n;
  scanf("%d", &n);
  for (int i = 1, cnt = 0; i <= np; ++i) {
    if (rv(prime[i]) != prime[i] && !notprime[rv(prime[i])]) {
      ++cnt;
      if (cnt == n) {
        printf("%d\n", prime[i]);
        return 0;
      }
    }
  }
  throw 13332333;
}

```