#include <bits/stdc++.h>
int asal(int x) {
  int i, n = (int)sqrt(x);
  for (i = 2; i <= n; i++) {
    if (x % i == 0) return 0;
  }
  return 1;
}
int ters(long long k) {
  int n = 0;
  while (k) {
    n *= 10;
    n += k % 10;
    k /= 10;
  }
  return n;
}
long long k, i, l, j;
int main() {
  int n, sayac = 0;
  i = 10;
  scanf("%d", &n);
  while (i++) {
    l = ters(i);
    if (asal(i) && i != l && asal(l)) sayac++;
    if (sayac == n) {
      printf("%I64d\n", i);
      return 0;
    }
  }
  return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

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 asal(int x) {
  int i, n = (int)sqrt(x);
  for (i = 2; i <= n; i++) {
    if (x % i == 0) return 0;
  }
  return 1;
}
int ters(long long k) {
  int n = 0;
  while (k) {
    n *= 10;
    n += k % 10;
    k /= 10;
  }
  return n;
}
long long k, i, l, j;
int main() {
  int n, sayac = 0;
  i = 10;
  scanf("%d", &n);
  while (i++) {
    l = ters(i);
    if (asal(i) && i != l && asal(l)) sayac++;
    if (sayac == n) {
      printf("%I64d\n", i);
      return 0;
    }
  }
  return 0;
}

```