#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000000;
int prime[MAXN + 10];
int hsh[MAXN + 10];
int n, cnt, lst;
int read(void) {
  scanf("%d", &n);
  return 0;
}
int init(void) {
  lst = cnt = 0;
  hsh[0] = hsh[1] = 1;
  for (int i = 2; i <= 1000000; i++) {
    if (!hsh[i]) prime[++cnt] = i;
    for (int j = 1; j <= cnt && i * prime[j] <= 1000000; j++) {
      hsh[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
  return 0;
}
int str[10];
int rt(int in) {
  for (int i = 0; i < 10 && in; i++) {
    str[i] = 1 + (in % 10);
    in /= 10;
  }
  int tempb = 0;
  for (int i = 0; str[i]; i++) {
    tempb *= 10;
    tempb += str[i] - 1;
  }
  return tempb;
}
int solve(void) {
  for (int i = 1; i <= 1000000; i++)
    if (!hsh[i]) {
      int j = rt(i);
      if (i != j && !hsh[j]) {
        lst++;
        if (lst == n) {
          printf("%d\n", i);
          return 0;
        }
      }
    }
  return 0;
}
int main(void) {
  read();
  init();
  solve();
  return 0;
}

### Prompt

Develop a solution in cpp to the problem described below:

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 MAXN = 1000000;
int prime[MAXN + 10];
int hsh[MAXN + 10];
int n, cnt, lst;
int read(void) {
  scanf("%d", &n);
  return 0;
}
int init(void) {
  lst = cnt = 0;
  hsh[0] = hsh[1] = 1;
  for (int i = 2; i <= 1000000; i++) {
    if (!hsh[i]) prime[++cnt] = i;
    for (int j = 1; j <= cnt && i * prime[j] <= 1000000; j++) {
      hsh[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
  return 0;
}
int str[10];
int rt(int in) {
  for (int i = 0; i < 10 && in; i++) {
    str[i] = 1 + (in % 10);
    in /= 10;
  }
  int tempb = 0;
  for (int i = 0; str[i]; i++) {
    tempb *= 10;
    tempb += str[i] - 1;
  }
  return tempb;
}
int solve(void) {
  for (int i = 1; i <= 1000000; i++)
    if (!hsh[i]) {
      int j = rt(i);
      if (i != j && !hsh[j]) {
        lst++;
        if (lst == n) {
          printf("%d\n", i);
          return 0;
        }
      }
    }
  return 0;
}
int main(void) {
  read();
  init();
  solve();
  return 0;
}

```