#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
int a, b, c, d, i, j, n, m, k;
inline bool prime(int a) {
  for (int i = 2; i * i <= a; ++i)
    if (a % i == 0) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int _n(1000000000), i(2); i <= _n; i++) {
    if (!prime(i)) continue;
    a = i, b = 0;
    while (a) {
      b = b * 10 + a % 10;
      a /= 10;
    }
    if (b == i || !prime(b)) continue;
    --n;
    if (!n) {
      printf("%d\n", i);
      exit(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>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
int a, b, c, d, i, j, n, m, k;
inline bool prime(int a) {
  for (int i = 2; i * i <= a; ++i)
    if (a % i == 0) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int _n(1000000000), i(2); i <= _n; i++) {
    if (!prime(i)) continue;
    a = i, b = 0;
    while (a) {
      b = b * 10 + a % 10;
      a /= 10;
    }
    if (b == i || !prime(b)) continue;
    --n;
    if (!n) {
      printf("%d\n", i);
      exit(0);
    }
  }
}

```