#include <bits/stdc++.h>
using namespace std;
const int N = 12000;
const double eps = 1e-9;
const int oo = 1000000000;
int pc;
int prime[N];
inline int reverse(int i) {
  int ret = 0;
  while (i) {
    ret = ret * 10 + i % 10;
    i /= 10;
  }
  return ret;
}
inline bool isprime(int x) {
  for (int i = 2; (long long)i * i <= x; ++i) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
void make_prime() {
  int i = 13;
  pc = 0;
  while (pc < 11184) {
    int j = reverse(i);
    if (i != j && isprime(i) && isprime(j)) {
      prime[pc++] = i;
    }
    ++i;
  }
}
int main() {
  make_prime();
  sort(prime, prime + pc);
  int a;
  cin >> a;
  cout << prime[a - 1] << endl;
  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;
const int N = 12000;
const double eps = 1e-9;
const int oo = 1000000000;
int pc;
int prime[N];
inline int reverse(int i) {
  int ret = 0;
  while (i) {
    ret = ret * 10 + i % 10;
    i /= 10;
  }
  return ret;
}
inline bool isprime(int x) {
  for (int i = 2; (long long)i * i <= x; ++i) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
void make_prime() {
  int i = 13;
  pc = 0;
  while (pc < 11184) {
    int j = reverse(i);
    if (i != j && isprime(i) && isprime(j)) {
      prime[pc++] = i;
    }
    ++i;
  }
}
int main() {
  make_prime();
  sort(prime, prime + pc);
  int a;
  cin >> a;
  cout << prime[a - 1] << endl;
  return 0;
}

```