#include <bits/stdc++.h>
template <typename T>
T inline SQR(const T &a) {
  return a * a;
}
template <typename T>
T inline ABS(const T &a) {
  return a < 0 ? -a : a;
}
const double EPS = 1e-9;
inline int SGN(double a) {
  return ((a > EPS) ? (1) : ((a < -EPS) ? (-1) : (0)));
}
inline int CMP(double a, double b) { return SGN(a - b); }
using namespace std;
bitset<1000000 + 10> bs;
vector<long long> primes;
void sieve() {
  for (int i = 0; i < 1000000 + 1; ++i) bs[i] = (i & 1);
  bs[1] = 0;
  bs[2] = 1;
  primes.push_back(2);
  for (int i = 3; i <= 1000000; i += 2)
    if (bs[i]) {
      primes.push_back(i);
      if (i > 1000) continue;
      for (int j = i * i; j <= 1000000; j += i) bs[j] = false;
    }
}
bool isPrime(long long N) {
  if (N <= 1000000) return bs.test(N);
  for (int i = 0; i < int((primes).size()); ++i)
    if (N % primes[i] == 0) return false;
  return true;
}
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  sieve();
  int n;
  cin >> n;
  int cnt = 0;
  long long x = 2;
  while (true) {
    if (isPrime(x)) {
      long long rev = 0;
      long long aux = x;
      while (aux) {
        rev = 10LL * rev + (aux % 10);
        aux /= 10;
      }
      if (rev != x && isPrime(rev)) {
        cnt++;
        if (cnt == n) {
          cout << x << "\n";
          goto hell;
        }
      }
    }
    x++;
  }
hell:;
  return 0;
}

### Prompt

In CPP, your task is to solve 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>
template <typename T>
T inline SQR(const T &a) {
  return a * a;
}
template <typename T>
T inline ABS(const T &a) {
  return a < 0 ? -a : a;
}
const double EPS = 1e-9;
inline int SGN(double a) {
  return ((a > EPS) ? (1) : ((a < -EPS) ? (-1) : (0)));
}
inline int CMP(double a, double b) { return SGN(a - b); }
using namespace std;
bitset<1000000 + 10> bs;
vector<long long> primes;
void sieve() {
  for (int i = 0; i < 1000000 + 1; ++i) bs[i] = (i & 1);
  bs[1] = 0;
  bs[2] = 1;
  primes.push_back(2);
  for (int i = 3; i <= 1000000; i += 2)
    if (bs[i]) {
      primes.push_back(i);
      if (i > 1000) continue;
      for (int j = i * i; j <= 1000000; j += i) bs[j] = false;
    }
}
bool isPrime(long long N) {
  if (N <= 1000000) return bs.test(N);
  for (int i = 0; i < int((primes).size()); ++i)
    if (N % primes[i] == 0) return false;
  return true;
}
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  sieve();
  int n;
  cin >> n;
  int cnt = 0;
  long long x = 2;
  while (true) {
    if (isPrime(x)) {
      long long rev = 0;
      long long aux = x;
      while (aux) {
        rev = 10LL * rev + (aux % 10);
        aux /= 10;
      }
      if (rev != x && isPrime(rev)) {
        cnt++;
        if (cnt == n) {
          cout << x << "\n";
          goto hell;
        }
      }
    }
    x++;
  }
hell:;
  return 0;
}

```