#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 11;
bool mark[N];
bool isPrime(int n) {
  bool p, q;
  p = q = true;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) p = false;
  p &= (n > 1);
  int nn = 0;
  for (int i = n; i > 0; i /= 10) {
    int r = i % 10;
    nn = nn * 10 + r;
  }
  for (int i = 2; i * i <= nn; i++)
    if (nn % i == 0) q = false;
  q &= (nn > 1);
  return (p & q) && (n != nn);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 2; i < N; i++) {
    if (mark[i] || i * 1LL * i >= N) continue;
    for (int j = i * i; j < N; j += i) mark[j] = true;
  }
  int id = 0;
  for (int i = 2; i < N; i++) {
    if (mark[i]) continue;
    if (isPrime(i)) {
      ++id;
      if (id == n) {
        cout << i << '\n';
        return 0;
      }
    }
  }
  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>
using namespace std;
const int N = 1e6 + 11;
bool mark[N];
bool isPrime(int n) {
  bool p, q;
  p = q = true;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) p = false;
  p &= (n > 1);
  int nn = 0;
  for (int i = n; i > 0; i /= 10) {
    int r = i % 10;
    nn = nn * 10 + r;
  }
  for (int i = 2; i * i <= nn; i++)
    if (nn % i == 0) q = false;
  q &= (nn > 1);
  return (p & q) && (n != nn);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 2; i < N; i++) {
    if (mark[i] || i * 1LL * i >= N) continue;
    for (int j = i * i; j < N; j += i) mark[j] = true;
  }
  int id = 0;
  for (int i = 2; i < N; i++) {
    if (mark[i]) continue;
    if (isPrime(i)) {
      ++id;
      if (id == n) {
        cout << i << '\n';
        return 0;
      }
    }
  }
  return 0;
}

```