#include <bits/stdc++.h>
using namespace std;
const unsigned long long INF = ~0ull;
const int N = 1e6 + 15;
bool used[N];
int a[N], apos;
void init() {
  memset(used, true, sizeof(used));
  apos = 1;
  used[0] = used[1] = false;
  for (int i = 2; i < N; i++) {
    if (used[i]) {
      for (int j = 2; i * j < N; j++) {
        used[i * j] = false;
      }
    }
  }
}
int reverse(int x) {
  int ans = 0;
  while (x) {
    ans = ans * 10 + x % 10;
    x /= 10;
  }
  return ans;
}
int main() {
  init();
  int n = 0;
  for (int i = 2; n < 11184; i++) {
    int x = i;
    int y = reverse(x);
    if (x != y && used[x] && used[y]) {
      a[apos++] = x;
      n++;
    }
  }
  int in;
  while (~scanf("%d", &in)) {
    printf("%d\n", a[in]);
  }
  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;
const unsigned long long INF = ~0ull;
const int N = 1e6 + 15;
bool used[N];
int a[N], apos;
void init() {
  memset(used, true, sizeof(used));
  apos = 1;
  used[0] = used[1] = false;
  for (int i = 2; i < N; i++) {
    if (used[i]) {
      for (int j = 2; i * j < N; j++) {
        used[i * j] = false;
      }
    }
  }
}
int reverse(int x) {
  int ans = 0;
  while (x) {
    ans = ans * 10 + x % 10;
    x /= 10;
  }
  return ans;
}
int main() {
  init();
  int n = 0;
  for (int i = 2; n < 11184; i++) {
    int x = i;
    int y = reverse(x);
    if (x != y && used[x] && used[y]) {
      a[apos++] = x;
      n++;
    }
  }
  int in;
  while (~scanf("%d", &in)) {
    printf("%d\n", a[in]);
  }
  return 0;
}

```