#include <bits/stdc++.h>
using namespace std;
const int MAX_SEIVE = 1000000;
bool is_prime[MAX_SEIVE + 1];
void seive() {
  memset(is_prime, true, sizeof(is_prime));
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i * i <= MAX_SEIVE; i++)
    if (is_prime[i]) {
      for (int j = i << 1; j <= MAX_SEIVE; j += i) {
        is_prime[j] = false;
      }
    }
}
int rev(int);
int main() {
  seive();
  int n;
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 13;; ++i)
    if (is_prime[i]) {
      int r = rev(i);
      if (i != r && is_prime[r]) {
        if (++cnt == n) {
          printf("%d\n", i);
          return 0;
        }
      }
    }
  return 0;
}
int rev(int x) {
  stringstream s;
  s << x;
  string r = s.str();
  reverse(r.begin(), r.end());
  stringstream ss(r);
  int ret;
  ss >> ret;
  return ret;
}

### Prompt

Please formulate 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 MAX_SEIVE = 1000000;
bool is_prime[MAX_SEIVE + 1];
void seive() {
  memset(is_prime, true, sizeof(is_prime));
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i * i <= MAX_SEIVE; i++)
    if (is_prime[i]) {
      for (int j = i << 1; j <= MAX_SEIVE; j += i) {
        is_prime[j] = false;
      }
    }
}
int rev(int);
int main() {
  seive();
  int n;
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 13;; ++i)
    if (is_prime[i]) {
      int r = rev(i);
      if (i != r && is_prime[r]) {
        if (++cnt == n) {
          printf("%d\n", i);
          return 0;
        }
      }
    }
  return 0;
}
int rev(int x) {
  stringstream s;
  s << x;
  string r = s.str();
  reverse(r.begin(), r.end());
  stringstream ss(r);
  int ret;
  ss >> ret;
  return ret;
}

```