#include <bits/stdc++.h>
bool prime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return (false);
  return (true);
}
int reverse(int x) {
  int ret = 0;
  while (x) {
    ret = ret * 10 + x % 10;
    x /= 10;
  }
  return (ret);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 10;; i++) {
    if (prime(i) && prime(reverse(i)) && i != reverse(i)) n--;
    if (n == 0) {
      printf("%d\n", i);
      break;
    }
  }
  return (0);
}

### Prompt

Your task is to create a Cpp solution to the following problem:

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 prime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return (false);
  return (true);
}
int reverse(int x) {
  int ret = 0;
  while (x) {
    ret = ret * 10 + x % 10;
    x /= 10;
  }
  return (ret);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 10;; i++) {
    if (prime(i) && prime(reverse(i)) && i != reverse(i)) n--;
    if (n == 0) {
      printf("%d\n", i);
      break;
    }
  }
  return (0);
}

```