#include <bits/stdc++.h>
using namespace std;
bool asal(int t) {
  int i, j;
  if (t == 2 || t == 3) return 1;
  if (t % 2 == 0) return 0;
  j = sqrt(t) + 2;
  for (i = 3; i <= j; i += 2)
    if (t % i == 0) return 0;
  return 1;
}
int main() {
  int N;
  cin >> N;
  int i = 11, s = 0;
  int b, d;
  s = 0, i;
  for (i = 13; i; i += 2) {
    b = i;
    d = 0;
    while (b) {
      d = (d * 10) + b % 10;
      b /= 10;
    }
    if (d != i && asal(i) && asal(d)) s++;
    if (s == N) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

### Prompt

Create a solution in cpp for 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;
bool asal(int t) {
  int i, j;
  if (t == 2 || t == 3) return 1;
  if (t % 2 == 0) return 0;
  j = sqrt(t) + 2;
  for (i = 3; i <= j; i += 2)
    if (t % i == 0) return 0;
  return 1;
}
int main() {
  int N;
  cin >> N;
  int i = 11, s = 0;
  int b, d;
  s = 0, i;
  for (i = 13; i; i += 2) {
    b = i;
    d = 0;
    while (b) {
      d = (d * 10) + b % 10;
      b /= 10;
    }
    if (d != i && asal(i) && asal(d)) s++;
    if (s == N) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

```