#include <bits/stdc++.h>
using namespace std;
bool prime(int x) {
  int sq = sqrt(x);
  for (int i = 2; i <= sq; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 13; i <= 1000000; i++) {
    if (!prime(i)) continue;
    int a = i, b = 0;
    while (a) {
      b = b * 10 + a % 10;
      a /= 10;
    }
    if (b == i || !prime(b)) continue;
    n--;
    if (n == 0) {
      printf("%d\n", i);
      return 0;
    }
  }
}

### Prompt

Create a solution in Cpp for 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>
using namespace std;
bool prime(int x) {
  int sq = sqrt(x);
  for (int i = 2; i <= sq; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 13; i <= 1000000; i++) {
    if (!prime(i)) continue;
    int a = i, b = 0;
    while (a) {
      b = b * 10 + a % 10;
      a /= 10;
    }
    if (b == i || !prime(b)) continue;
    n--;
    if (n == 0) {
      printf("%d\n", i);
      return 0;
    }
  }
}

```