#include <bits/stdc++.h>
using namespace std;
int n, k, x, ans = 0;
bool p[1000001];
int main() {
  std::cin.tie(0);
  n = 1000000;
  memset(p, true, sizeof(p));
  p[0] = 0;
  p[1] = 0;
  for (int i = 2; i <= sqrt(n); i++) {
    if (p[i]) {
      for (int j = i + i; j <= n; j += i) {
        p[j] = false;
      }
    }
  }
  scanf("%d", &n);
  for (int i = 11; i <= 1000000; i += 2) {
    if (!p[i]) continue;
    k = 0;
    x = i;
    while (x) {
      k *= 10;
      k += x % 10;
      x /= 10;
    }
    if (i != k && p[i] && p[k]) {
      ans++;
    }
    if (ans == n) {
      printf("%d", i);
      break;
    }
  }
  return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

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 n, k, x, ans = 0;
bool p[1000001];
int main() {
  std::cin.tie(0);
  n = 1000000;
  memset(p, true, sizeof(p));
  p[0] = 0;
  p[1] = 0;
  for (int i = 2; i <= sqrt(n); i++) {
    if (p[i]) {
      for (int j = i + i; j <= n; j += i) {
        p[j] = false;
      }
    }
  }
  scanf("%d", &n);
  for (int i = 11; i <= 1000000; i += 2) {
    if (!p[i]) continue;
    k = 0;
    x = i;
    while (x) {
      k *= 10;
      k += x % 10;
      x /= 10;
    }
    if (i != k && p[i] && p[k]) {
      ans++;
    }
    if (ans == n) {
      printf("%d", i);
      break;
    }
  }
  return 0;
}

```