#include <bits/stdc++.h>
bool isPrime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
int rev(int x) {
  int r = 0;
  for (; x; x /= 10) r = r * 10 + x % 10;
  return r;
}
int main() {
  int n, i, k = 0;
  scanf("%d", &n);
  for (i = 0; i <= 999983; i++)
    if (i != rev(i) && isPrime(rev(i)) && isPrime(i))
      if (++k == n) {
        printf("%d\n", i);
        break;
      }
  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>
bool isPrime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
int rev(int x) {
  int r = 0;
  for (; x; x /= 10) r = r * 10 + x % 10;
  return r;
}
int main() {
  int n, i, k = 0;
  scanf("%d", &n);
  for (i = 0; i <= 999983; i++)
    if (i != rev(i) && isPrime(rev(i)) && isPrime(i))
      if (++k == n) {
        printf("%d\n", i);
        break;
      }
  return 0;
}

```