#include <bits/stdc++.h>
int a[11185];
int prime(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return 0;
  }
  return 1;
}
void mainn() {
  int k = 1;
  for (int i = 12; i <= 999998; i++) {
    if (prime(i)) {
      int m = i;
      int sum = 0;
      while (m) {
        sum = sum * 10 + m % 10;
        m = m / 10;
      }
      if (prime(sum) && sum != i) a[k++] = i;
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  mainn();
  printf("%d\n", a[n]);
}

### 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>
int a[11185];
int prime(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return 0;
  }
  return 1;
}
void mainn() {
  int k = 1;
  for (int i = 12; i <= 999998; i++) {
    if (prime(i)) {
      int m = i;
      int sum = 0;
      while (m) {
        sum = sum * 10 + m % 10;
        m = m / 10;
      }
      if (prime(sum) && sum != i) a[k++] = i;
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  mainn();
  printf("%d\n", a[n]);
}

```