#include <bits/stdc++.h>
int mirror(int x) {
  int i, t = x / 10;
  for (i = 1; t > 0; i *= 10) t /= 10;
  for (t = 0; i > 0; x /= 10, i /= 10) t += (x % 10) * i;
  return t;
}
int isprime(int x) {
  int i;
  if (x % 2 == 0) return 0;
  for (i = 3; i <= round(sqrt(x)) + 1; i += 2)
    if (x % i == 0) return 0;
  return 1;
}
int mirp(int n) {
  int x = 13, j = 1, m;
  while (j < n) {
    x += 2;
    m = mirror(x);
    if (m != x)
      if (isprime(x) && isprime(m)) ++j;
  }
  return x;
}
int main() {
  int n, m;
  fscanf(stdin, "%d", &n);
  m = mirp(n);
  printf("%d\n", m);
  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 mirror(int x) {
  int i, t = x / 10;
  for (i = 1; t > 0; i *= 10) t /= 10;
  for (t = 0; i > 0; x /= 10, i /= 10) t += (x % 10) * i;
  return t;
}
int isprime(int x) {
  int i;
  if (x % 2 == 0) return 0;
  for (i = 3; i <= round(sqrt(x)) + 1; i += 2)
    if (x % i == 0) return 0;
  return 1;
}
int mirp(int n) {
  int x = 13, j = 1, m;
  while (j < n) {
    x += 2;
    m = mirror(x);
    if (m != x)
      if (isprime(x) && isprime(m)) ++j;
  }
  return x;
}
int main() {
  int n, m;
  fscanf(stdin, "%d", &n);
  m = mirp(n);
  printf("%d\n", m);
  return 0;
}

```