#include <bits/stdc++.h>
using namespace std;
int asal(long long a) {
  int i, sayac = 0;
  for (i = 2; i <= sqrt(a); i++)
    if (a % i == 0) return 0;
  return 1;
}
int pal(long long a) {
  int z = 0, k, m;
  m = a;
  while (a) {
    z *= 10;
    z += a % 10;
    a /= 10;
  }
  if (m == z) return 0;
  k = asal(z);
  return k;
}
int main() {
  long long a, b, c, d, k, e, f, i, j, cnt = 0, cn;
  cin >> a;
  for (i = 13;; i++) {
    if (asal(i)) {
      if (pal(i)) cnt++;
      if (cnt == a) {
        printf("%d", i);
        return 0;
      }
    }
  }
  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>
using namespace std;
int asal(long long a) {
  int i, sayac = 0;
  for (i = 2; i <= sqrt(a); i++)
    if (a % i == 0) return 0;
  return 1;
}
int pal(long long a) {
  int z = 0, k, m;
  m = a;
  while (a) {
    z *= 10;
    z += a % 10;
    a /= 10;
  }
  if (m == z) return 0;
  k = asal(z);
  return k;
}
int main() {
  long long a, b, c, d, k, e, f, i, j, cnt = 0, cn;
  cin >> a;
  for (i = 13;; i++) {
    if (asal(i)) {
      if (pal(i)) cnt++;
      if (cnt == a) {
        printf("%d", i);
        return 0;
      }
    }
  }
  return 0;
}

```