#include <bits/stdc++.h>
int ans[11185], an;
int prime[1000000 / 2], pn;
bool unprime[1000000];
void get_prime() {
  pn = 0;
  memset(unprime, 0, sizeof(unprime));
  int i, j;
  unprime[1] = 1;
  for (i = 2; i < 1000000; i++) {
    if (!unprime[i]) {
      prime[pn++] = i;
      if (i > 10000) continue;
      for (j = i * i; j < 1000000; j += i) unprime[j] = 1;
    }
  }
}
int rev(int x) {
  int i, res = 0;
  while (x) {
    res = res * 10 + x % 10;
    x /= 10;
  }
  return res;
}
void pre() {
  an = 0;
  int temp;
  for (int i = 0; i < pn; i++) {
    temp = rev(prime[i]);
    if (temp != prime[i] && !unprime[temp]) ans[an++] = prime[i];
  }
}
int main() {
  get_prime();
  pre();
  int n;
  scanf("%d", &n);
  printf("%d\n", ans[n - 1]);
  return 0;
}

### Prompt

Please provide a cpp coded solution 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>
int ans[11185], an;
int prime[1000000 / 2], pn;
bool unprime[1000000];
void get_prime() {
  pn = 0;
  memset(unprime, 0, sizeof(unprime));
  int i, j;
  unprime[1] = 1;
  for (i = 2; i < 1000000; i++) {
    if (!unprime[i]) {
      prime[pn++] = i;
      if (i > 10000) continue;
      for (j = i * i; j < 1000000; j += i) unprime[j] = 1;
    }
  }
}
int rev(int x) {
  int i, res = 0;
  while (x) {
    res = res * 10 + x % 10;
    x /= 10;
  }
  return res;
}
void pre() {
  an = 0;
  int temp;
  for (int i = 0; i < pn; i++) {
    temp = rev(prime[i]);
    if (temp != prime[i] && !unprime[temp]) ans[an++] = prime[i];
  }
}
int main() {
  get_prime();
  pre();
  int n;
  scanf("%d", &n);
  printf("%d\n", ans[n - 1]);
  return 0;
}

```