#include <bits/stdc++.h>
using namespace std;
inline int rev(int n) {
  int r = 0;
  while (n != 0) {
    r = 10 * r + n % 10;
    n /= 10;
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  const int MAX = 1e6;
  int SQRT_MAX = 1e3;
  bitset<MAX + 1> sieve;
  sieve.set(0);
  sieve.set(1);
  for (int i = 4; i <= MAX; i += 2) sieve.set(i);
  for (int i = 3, j; i <= SQRT_MAX;) {
    for (j = i * i; j <= MAX; j += (i << 1)) sieve.set(j);
    while ((i += 2) <= SQRT_MAX && sieve[i])
      ;
  }
  sieve.flip();
  int idx = 0;
  for (int i = 2;; ++i) {
    if (!sieve.test(i)) continue;
    int r = rev(i);
    if (i == r || !sieve.test(r)) continue;
    ++idx;
    if (idx == n) {
      cout << i;
      return 0;
    }
  }
  return 0;
}

### Prompt

Please create a solution in CPP 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;
inline int rev(int n) {
  int r = 0;
  while (n != 0) {
    r = 10 * r + n % 10;
    n /= 10;
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  const int MAX = 1e6;
  int SQRT_MAX = 1e3;
  bitset<MAX + 1> sieve;
  sieve.set(0);
  sieve.set(1);
  for (int i = 4; i <= MAX; i += 2) sieve.set(i);
  for (int i = 3, j; i <= SQRT_MAX;) {
    for (j = i * i; j <= MAX; j += (i << 1)) sieve.set(j);
    while ((i += 2) <= SQRT_MAX && sieve[i])
      ;
  }
  sieve.flip();
  int idx = 0;
  for (int i = 2;; ++i) {
    if (!sieve.test(i)) continue;
    int r = rev(i);
    if (i == r || !sieve.test(r)) continue;
    ++idx;
    if (idx == n) {
      cout << i;
      return 0;
    }
  }
  return 0;
}

```