#include <bits/stdc++.h>
using namespace std;
int a, b, c, n;
bool isprime(int now) {
  for (int i = 2; i * i <= now; ++i)
    if (now % i == 0) return 0;
  return 1;
}
int rev(int now) {
  int ret = 0;
  for (; now; now /= 10) ret *= 10, ret += now % 10;
  return ret;
}
int main() {
  cin >> n;
  for (int i = 13;; ++i) {
    if (isprime(i) && isprime(rev(i)) && rev(i) != i) n--;
    if (!n) {
      cout << i << endl;
      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 a, b, c, n;
bool isprime(int now) {
  for (int i = 2; i * i <= now; ++i)
    if (now % i == 0) return 0;
  return 1;
}
int rev(int now) {
  int ret = 0;
  for (; now; now /= 10) ret *= 10, ret += now % 10;
  return ret;
}
int main() {
  cin >> n;
  for (int i = 13;; ++i) {
    if (isprime(i) && isprime(rev(i)) && rev(i) != i) n--;
    if (!n) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

```