#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return b != 0 ? GCD(b, a % b) : a; }
long long LCM(long long a, long long b) { return a * (b / GCD(a, b)); }
long long Pow(long long n, long long e) {
  if (e == 0) return 1;
  if (e == 1)
    return n;
  else if (e & 1) {
    long long t = Pow(n, e / 2);
    return n * t * t;
  } else {
    long long t = Pow(n, e / 2);
    return t * t;
  }
}
string s[3] = {
    "qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. "
    "oekh jqia yi je vydt jxu djx ucyhf.",
    "jxu ydfkj sediyiji ev q iydwbu ydjuwuh",
    "jxu edu-rqiut ydtun ev jxu ucyhf je vydt"};
const int PRIMES = 1000000;
bitset<PRIMES> bs;
vector<int> prime;
void GeneratePrimes() {
  bs.set();
  bs[0] = 0;
  bs[1] = 0;
  for (int i = (2), max_ = (PRIMES); i < max_; ++i)
    if (bs[i]) {
      prime.push_back(i);
      long long j = i * (long long)i;
      while (j < PRIMES) {
        bs[j] = false;
        j += i;
      }
    }
}
int main() {
  GeneratePrimes();
  vector<int> emirp;
  for (int i = 0, max_ = ((int)(prime).size()); i < max_; ++i) {
    stringstream ss;
    ss << prime[i];
    string s = ss.str();
    reverse((s).begin(), (s).end());
    int p = 0;
    for (int j = 0, max_ = ((int)(s).size()); j < max_; ++j)
      p = 10 * p + s[j] - '0';
    if (prime[i] != p && bs[p]) emirp.push_back(prime[i]);
  }
  int N;
  scanf("%d", &N);
  printf("%d\n", emirp[N - 1]);
  return 0;
}

### Prompt

Please formulate 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;
long long GCD(long long a, long long b) { return b != 0 ? GCD(b, a % b) : a; }
long long LCM(long long a, long long b) { return a * (b / GCD(a, b)); }
long long Pow(long long n, long long e) {
  if (e == 0) return 1;
  if (e == 1)
    return n;
  else if (e & 1) {
    long long t = Pow(n, e / 2);
    return n * t * t;
  } else {
    long long t = Pow(n, e / 2);
    return t * t;
  }
}
string s[3] = {
    "qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. "
    "oekh jqia yi je vydt jxu djx ucyhf.",
    "jxu ydfkj sediyiji ev q iydwbu ydjuwuh",
    "jxu edu-rqiut ydtun ev jxu ucyhf je vydt"};
const int PRIMES = 1000000;
bitset<PRIMES> bs;
vector<int> prime;
void GeneratePrimes() {
  bs.set();
  bs[0] = 0;
  bs[1] = 0;
  for (int i = (2), max_ = (PRIMES); i < max_; ++i)
    if (bs[i]) {
      prime.push_back(i);
      long long j = i * (long long)i;
      while (j < PRIMES) {
        bs[j] = false;
        j += i;
      }
    }
}
int main() {
  GeneratePrimes();
  vector<int> emirp;
  for (int i = 0, max_ = ((int)(prime).size()); i < max_; ++i) {
    stringstream ss;
    ss << prime[i];
    string s = ss.str();
    reverse((s).begin(), (s).end());
    int p = 0;
    for (int j = 0, max_ = ((int)(s).size()); j < max_; ++j)
      p = 10 * p + s[j] - '0';
    if (prime[i] != p && bs[p]) emirp.push_back(prime[i]);
  }
  int N;
  scanf("%d", &N);
  printf("%d\n", emirp[N - 1]);
  return 0;
}

```