#include <bits/stdc++.h>
using namespace std;
int n, m;
bool debug = false;
int k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
bitset<1000005> bs;
void init() {
  for (int i = 3; i * i <= 1000005; i += 2)
    if (!bs[i]) {
      for (int j = i * i; j <= 1000005; j += i + i) {
        bs[j] = 1;
      }
    }
}
bool isP(int x) { return x % 2 != 0 && !bs[x]; }
int rev(int x) {
  int s = 0;
  while (x > 0) {
    s = s * 10 + x % 10;
    x /= 10;
  }
  return s;
}
int main() {
  init();
  scanf("%d", &n);
  int i, ri, c;
  for (i = 13, ri = rev(i), c = 0; c < n; i++, ri = rev(i)) {
    if (i != ri && isP(i) && isP(ri)) c++;
    if (c == n) break;
  }
  printf("%d\n", i);
  return 0;
}

### Prompt

Your task is to create 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 n, m;
bool debug = false;
int k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
bitset<1000005> bs;
void init() {
  for (int i = 3; i * i <= 1000005; i += 2)
    if (!bs[i]) {
      for (int j = i * i; j <= 1000005; j += i + i) {
        bs[j] = 1;
      }
    }
}
bool isP(int x) { return x % 2 != 0 && !bs[x]; }
int rev(int x) {
  int s = 0;
  while (x > 0) {
    s = s * 10 + x % 10;
    x /= 10;
  }
  return s;
}
int main() {
  init();
  scanf("%d", &n);
  int i, ri, c;
  for (i = 13, ri = rev(i), c = 0; c < n; i++, ri = rev(i)) {
    if (i != ri && isP(i) && isP(ri)) c++;
    if (c == n) break;
  }
  printf("%d\n", i);
  return 0;
}

```