#include <bits/stdc++.h>
using namespace std;
bool prime(int a) {
  for (int i = 2; i * i <= a; i++) {
    if (a % i == 0) return 0;
  }
  return 1;
}
int mirrow(int n) {
  int c = 0;
  while (n) {
    c = c * 10 + n % 10;
    n /= 10;
  }
  return c;
}
int main() {
  int n, num = 0;
  cin >> n;
  for (int i = 13; i <= 10000000; i++) {
    if (prime(i)) {
      if (prime(mirrow(i)) && i != mirrow(i)) {
        num++;
        if (num == n) {
          cout << i;
          return 0;
        }
      }
    }
  }
}

### Prompt

Please formulate 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>
using namespace std;
bool prime(int a) {
  for (int i = 2; i * i <= a; i++) {
    if (a % i == 0) return 0;
  }
  return 1;
}
int mirrow(int n) {
  int c = 0;
  while (n) {
    c = c * 10 + n % 10;
    n /= 10;
  }
  return c;
}
int main() {
  int n, num = 0;
  cin >> n;
  for (int i = 13; i <= 10000000; i++) {
    if (prime(i)) {
      if (prime(mirrow(i)) && i != mirrow(i)) {
        num++;
        if (num == n) {
          cout << i;
          return 0;
        }
      }
    }
  }
}

```