#include <bits/stdc++.h>
int diri[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dirj[] = {0, 1, 0, -1, 1, 1, -1, -1};
int compare(double d1, double d2) {
  if (fabs(d1 - d2) < 1e-9) return 0;
  if (d1 < d2) return -1;
  return 1;
}
using namespace std;
const int maxPrime = 1000001;
bool isPrime[maxPrime];
void sievePrime() {
  memset(isPrime, 1, sizeof(isPrime));
  int i, j;
  isPrime[0] = isPrime[1] = 0;
  for (i = 2; i * i <= maxPrime; i++) {
    if (isPrime[i])
      for (j = i * i; j < maxPrime; j += i) {
        isPrime[j] = 0;
      }
  }
}
int main() {
  int n;
  cin >> n;
  sievePrime();
  vector<int> ans;
  vector<int> prim;
  for (int i = 0; i < (int)maxPrime; i++) {
    if (isPrime[i]) {
      prim.push_back(i);
    }
  }
  for (int i = 0; i < (int)prim.size(); i++) {
    stringstream ss;
    string s;
    int t;
    ss << prim[i];
    ss >> s;
    reverse(s.begin(), s.end());
    stringstream tt(s);
    tt >> t;
    if (t != prim[i] && isPrime[t]) {
      ans.push_back(prim[i]);
    }
  }
  n--;
  cout << ans[n] << endl;
  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>
int diri[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dirj[] = {0, 1, 0, -1, 1, 1, -1, -1};
int compare(double d1, double d2) {
  if (fabs(d1 - d2) < 1e-9) return 0;
  if (d1 < d2) return -1;
  return 1;
}
using namespace std;
const int maxPrime = 1000001;
bool isPrime[maxPrime];
void sievePrime() {
  memset(isPrime, 1, sizeof(isPrime));
  int i, j;
  isPrime[0] = isPrime[1] = 0;
  for (i = 2; i * i <= maxPrime; i++) {
    if (isPrime[i])
      for (j = i * i; j < maxPrime; j += i) {
        isPrime[j] = 0;
      }
  }
}
int main() {
  int n;
  cin >> n;
  sievePrime();
  vector<int> ans;
  vector<int> prim;
  for (int i = 0; i < (int)maxPrime; i++) {
    if (isPrime[i]) {
      prim.push_back(i);
    }
  }
  for (int i = 0; i < (int)prim.size(); i++) {
    stringstream ss;
    string s;
    int t;
    ss << prim[i];
    ss >> s;
    reverse(s.begin(), s.end());
    stringstream tt(s);
    tt >> t;
    if (t != prim[i] && isPrime[t]) {
      ans.push_back(prim[i]);
    }
  }
  n--;
  cout << ans[n] << endl;
  return 0;
}

```