#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int maxN = 1000000;
  cin >> n;
  vector<bool> primes(maxN, true);
  set<int> emirps;
  set<int>::iterator it;
  for (int i = 2; i * i < maxN; i++) {
    if (primes[i]) {
      for (int j = i; i * j < maxN; j++) {
        primes[i * j] = false;
      }
    }
  }
  for (int i = 2; i < maxN; i++) {
    if (primes[i]) {
      emirps.insert(i);
    }
  }
  int nth = 0;
  it = emirps.begin();
  while (nth != n && it != emirps.end()) {
    int sv = *it;
    int rev = 0;
    while (sv > 0) {
      rev = rev * 10 + sv % 10;
      sv /= 10;
    }
    if (emirps.find(rev) != emirps.end() && *it / 10 > 0 && *it != rev) {
      nth++;
    }
    it++;
  }
  cout << *(--it);
  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 main() {
  int n;
  int maxN = 1000000;
  cin >> n;
  vector<bool> primes(maxN, true);
  set<int> emirps;
  set<int>::iterator it;
  for (int i = 2; i * i < maxN; i++) {
    if (primes[i]) {
      for (int j = i; i * j < maxN; j++) {
        primes[i * j] = false;
      }
    }
  }
  for (int i = 2; i < maxN; i++) {
    if (primes[i]) {
      emirps.insert(i);
    }
  }
  int nth = 0;
  it = emirps.begin();
  while (nth != n && it != emirps.end()) {
    int sv = *it;
    int rev = 0;
    while (sv > 0) {
      rev = rev * 10 + sv % 10;
      sv /= 10;
    }
    if (emirps.find(rev) != emirps.end() && *it / 10 > 0 && *it != rev) {
      nth++;
    }
    it++;
  }
  cout << *(--it);
  return 0;
}

```