#include <bits/stdc++.h>
using namespace std;
long long chk(long long n) {
  if (n < 2) return 0;
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i == 0) return 0;
  }
  return 1;
}
long long rev(long long n) {
  long long ans = 0;
  while (n) {
    ans *= 10;
    ans += (n % 10);
    n /= 10;
  }
  return ans;
}
int main(int argc, char const *argv[]) {
  long long d;
  cin >> d;
  for (long long i = 1;; ++i) {
    if ((i != rev(i)) && (chk(i) && chk(rev(i)))) {
      d--;
      if (d == 0) {
        cout << i << '\n';
        break;
      }
    }
  }
  return 0;
}

### Prompt

Your challenge is to write 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;
long long chk(long long n) {
  if (n < 2) return 0;
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i == 0) return 0;
  }
  return 1;
}
long long rev(long long n) {
  long long ans = 0;
  while (n) {
    ans *= 10;
    ans += (n % 10);
    n /= 10;
  }
  return ans;
}
int main(int argc, char const *argv[]) {
  long long d;
  cin >> d;
  for (long long i = 1;; ++i) {
    if ((i != rev(i)) && (chk(i) && chk(rev(i)))) {
      d--;
      if (d == 0) {
        cout << i << '\n';
        break;
      }
    }
  }
  return 0;
}

```