#include <bits/stdc++.h>
using namespace std;
int n;
long long fi = 13, g;
bool s[1000000];
bool f1(long long n) {
  if (n == 2) return 1;
  if (n % 2 == 0 || n < 2) return 0;
  for (int i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) {
      return 0;
    }
  }
  s[n] = 1;
  return 1;
}
long long f2(long long n) {
  long long gg = 0;
  while (n >= 1) {
    gg *= 10;
    gg += n % 10;
    n /= 10;
  }
  return gg;
}
int main() {
  cin >> n;
  s[1] = 0;
  s[2] = 1;
  for (int i = 0; i < n; fi += 2) {
    if (f1(fi) == 1) {
      g = f2(fi);
      if (((g < fi) && (s[g] == 1)) || ((g > fi) && (f1(g) == 1))) {
        i++;
        if (i == n) {
          cout << fi;
          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 n;
long long fi = 13, g;
bool s[1000000];
bool f1(long long n) {
  if (n == 2) return 1;
  if (n % 2 == 0 || n < 2) return 0;
  for (int i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) {
      return 0;
    }
  }
  s[n] = 1;
  return 1;
}
long long f2(long long n) {
  long long gg = 0;
  while (n >= 1) {
    gg *= 10;
    gg += n % 10;
    n /= 10;
  }
  return gg;
}
int main() {
  cin >> n;
  s[1] = 0;
  s[2] = 1;
  for (int i = 0; i < n; fi += 2) {
    if (f1(fi) == 1) {
      g = f2(fi);
      if (((g < fi) && (s[g] == 1)) || ((g > fi) && (f1(g) == 1))) {
        i++;
        if (i == n) {
          cout << fi;
          return 0;
        }
      }
    }
  }
}

```