#include <bits/stdc++.h>
using namespace std;
bool is_prime(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  int count = 0;
  for (int i = 13; i <= 1000000000; i++) {
    if (is_prime(i)) {
      stringstream ss;
      ss << i;
      string sb = ss.str();
      reverse(sb.begin(), sb.end());
      ss.str(sb);
      int nb;
      ss >> nb;
      if (is_prime(nb) && i != nb) {
        count++;
        if (count == n) {
          cout << i << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}

### Prompt

Generate 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 is_prime(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  int count = 0;
  for (int i = 13; i <= 1000000000; i++) {
    if (is_prime(i)) {
      stringstream ss;
      ss << i;
      string sb = ss.str();
      reverse(sb.begin(), sb.end());
      ss.str(sb);
      int nb;
      ss >> nb;
      if (is_prime(nb) && i != nb) {
        count++;
        if (count == n) {
          cout << i << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}

```