#include <bits/stdc++.h>
using namespace std;
bool pr(int n) {
  for (int i = 2; i <= int(sqrt(n * 1.0)); ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int z(int n) {
  int res = 0;
  while (n) {
    res *= 10;
    res += n % 10;
    n /= 10;
  }
  return res;
}
int main(void) {
  int a, k = 0, i = 12, q;
  cin >> a;
  while (k < a) {
    ++i;
    q = z(i);
    if (q != i && pr(i) && pr(q)) {
      ++k;
    }
  }
  cout << i;
  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;
bool pr(int n) {
  for (int i = 2; i <= int(sqrt(n * 1.0)); ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int z(int n) {
  int res = 0;
  while (n) {
    res *= 10;
    res += n % 10;
    n /= 10;
  }
  return res;
}
int main(void) {
  int a, k = 0, i = 12, q;
  cin >> a;
  while (k < a) {
    ++i;
    q = z(i);
    if (q != i && pr(i) && pr(q)) {
      ++k;
    }
  }
  cout << i;
  return 0;
}

```