#include <bits/stdc++.h>
using namespace std;
int M = 1000000;
bool *isprime = new bool[M];
void init() {
  memset(isprime, true, M * sizeof(bool));
  isprime[1] = false;
  for (int i = 2; i < M; ++i) {
    if (isprime[i]) {
      for (int j = 2 * i; j < M; j += i) isprime[j] = false;
    }
  }
}
int reverse(int n) {
  int res = 0;
  while (n) {
    res = res * 10 + n % 10;
    n /= 10;
  }
  return res;
}
int main() {
  init();
  int d, cnt = 0;
  cin >> d;
  for (int i = 2; i < M; ++i) {
    if (isprime[i]) {
      int ri = reverse(i);
      if (ri != i && isprime[ri]) cnt++;
    }
    if (cnt == d) {
      cout << i << endl;
      return 0;
    }
  }
  delete[] isprime;
  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;
int M = 1000000;
bool *isprime = new bool[M];
void init() {
  memset(isprime, true, M * sizeof(bool));
  isprime[1] = false;
  for (int i = 2; i < M; ++i) {
    if (isprime[i]) {
      for (int j = 2 * i; j < M; j += i) isprime[j] = false;
    }
  }
}
int reverse(int n) {
  int res = 0;
  while (n) {
    res = res * 10 + n % 10;
    n /= 10;
  }
  return res;
}
int main() {
  init();
  int d, cnt = 0;
  cin >> d;
  for (int i = 2; i < M; ++i) {
    if (isprime[i]) {
      int ri = reverse(i);
      if (ri != i && isprime[ri]) cnt++;
    }
    if (cnt == d) {
      cout << i << endl;
      return 0;
    }
  }
  delete[] isprime;
  return 0;
}

```