#include <bits/stdc++.h>
using namespace std;
vector<int> primes;
char isPrime[1000000];
void init() {
  primes.reserve(1000000);
  memset(isPrime, -1, sizeof(isPrime));
  isPrime[0] = isPrime[1] = 0;
  for (int i = 0; i * i < 1000000; i++) {
    if (!isPrime[i]) continue;
    for (int j = i * i; j < 1000000; j += i) isPrime[j] = 0;
  }
  for (int i = 0; i < 1000000; i++)
    if (isPrime[i]) primes.push_back(i);
}
int backwards(int n) {
  int cur = 0;
  while (n) {
    cur = (cur * 10 + n % 10);
    n /= 10;
  }
  return cur;
}
int main() {
  init();
  int n;
  cin >> n;
  int count = 0, cur = 0, bn;
  while (count < n) {
    bn = backwards(primes[cur]);
    if (bn != primes[cur++] && isPrime[bn]) count++;
  }
  cout << primes[cur - 1] << endl;
  return 0;
}

### Prompt

Your task is to create 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;
vector<int> primes;
char isPrime[1000000];
void init() {
  primes.reserve(1000000);
  memset(isPrime, -1, sizeof(isPrime));
  isPrime[0] = isPrime[1] = 0;
  for (int i = 0; i * i < 1000000; i++) {
    if (!isPrime[i]) continue;
    for (int j = i * i; j < 1000000; j += i) isPrime[j] = 0;
  }
  for (int i = 0; i < 1000000; i++)
    if (isPrime[i]) primes.push_back(i);
}
int backwards(int n) {
  int cur = 0;
  while (n) {
    cur = (cur * 10 + n % 10);
    n /= 10;
  }
  return cur;
}
int main() {
  init();
  int n;
  cin >> n;
  int count = 0, cur = 0, bn;
  while (count < n) {
    bn = backwards(primes[cur]);
    if (bn != primes[cur++] && isPrime[bn]) count++;
  }
  cout << primes[cur - 1] << endl;
  return 0;
}

```