#include <bits/stdc++.h>
long long int hash[1000005], i, j, n, h, yer, cvp[12000], a[78800];
long long int ters(long long int a) {
  int cvp[20] = {0}, i = 0, j, sonuc = 0, k = 1;
  while (a) {
    cvp[i] = a % 10;
    a /= 10;
    i++;
  }
  for (j = i - 1; j >= 0; j--) {
    sonuc += k * cvp[j];
    k *= 10;
  }
  return sonuc;
}
int main() {
  for (i = 2; i <= 1000000; i++) {
    if (hash[i]) continue;
    for (j = 2 * i; j <= 1000000; j += i) hash[j] = 1;
  }
  for (i = 0; i < 1000000; i++) {
    if (!hash[i]) {
      a[yer] = i;
      yer++;
    }
  }
  yer = 0;
  for (i = 2; i < 78600; i++) {
    if (!hash[ters(a[i])] && a[i] != ters(a[i])) {
      cvp[yer] = a[i];
      yer++;
    }
  }
  scanf("%lld", &n);
  printf("%lld", cvp[n - 1]);
  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>
long long int hash[1000005], i, j, n, h, yer, cvp[12000], a[78800];
long long int ters(long long int a) {
  int cvp[20] = {0}, i = 0, j, sonuc = 0, k = 1;
  while (a) {
    cvp[i] = a % 10;
    a /= 10;
    i++;
  }
  for (j = i - 1; j >= 0; j--) {
    sonuc += k * cvp[j];
    k *= 10;
  }
  return sonuc;
}
int main() {
  for (i = 2; i <= 1000000; i++) {
    if (hash[i]) continue;
    for (j = 2 * i; j <= 1000000; j += i) hash[j] = 1;
  }
  for (i = 0; i < 1000000; i++) {
    if (!hash[i]) {
      a[yer] = i;
      yer++;
    }
  }
  yer = 0;
  for (i = 2; i < 78600; i++) {
    if (!hash[ters(a[i])] && a[i] != ters(a[i])) {
      cvp[yer] = a[i];
      yer++;
    }
  }
  scanf("%lld", &n);
  printf("%lld", cvp[n - 1]);
  return 0;
}

```