#include <bits/stdc++.h>
using namespace std;
bool prime[10000000];
bool t[10000000];
vector<int> emirps;
bool f(int a) {
  int c = a;
  int k = 1;
  int b = 0;
  while (k < a) k *= 10;
  k /= 10;
  while (k) {
    b += (a % 10) * k;
    a /= 10;
    k /= 10;
  }
  if (!(b % 2) || prime[b] || b == c)
    return false;
  else {
    t[b] = true;
    return true;
  }
}
int main() {
  for (int i = 3; i < 10000000; i += 2) {
    if (!prime[i]) {
      for (int j = i * 3; j < 10000000; j += i * 2) prime[j] = true;
    }
  }
  for (int i = 13; i < 10000000; i += 2) {
    if (!prime[i] && (t[i] || f(i))) emirps.push_back(i);
  }
  int n;
  cin >> n;
  cout << emirps[n - 1] << endl;
  return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

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;
bool prime[10000000];
bool t[10000000];
vector<int> emirps;
bool f(int a) {
  int c = a;
  int k = 1;
  int b = 0;
  while (k < a) k *= 10;
  k /= 10;
  while (k) {
    b += (a % 10) * k;
    a /= 10;
    k /= 10;
  }
  if (!(b % 2) || prime[b] || b == c)
    return false;
  else {
    t[b] = true;
    return true;
  }
}
int main() {
  for (int i = 3; i < 10000000; i += 2) {
    if (!prime[i]) {
      for (int j = i * 3; j < 10000000; j += i * 2) prime[j] = true;
    }
  }
  for (int i = 13; i < 10000000; i += 2) {
    if (!prime[i] && (t[i] || f(i))) emirps.push_back(i);
  }
  int n;
  cin >> n;
  cout << emirps[n - 1] << endl;
  return 0;
}

```