#include <bits/stdc++.h>
using namespace std;
int rev(int x) {
  int ans = 0;
  while (x) {
    ans *= 10;
    ans += x % 10;
    x /= 10;
  }
  return ans;
}
bool is_prime(int n) {
  for (int i = 2; i * i <= n; ++i)
    if (n % i == 0) return false;
  return true;
}
bool emirp(int n) { return (n != rev(n) && is_prime(n) && is_prime(rev(n))); }
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int d;
  cin >> d;
  int n = 13;
  while (d) {
    if (emirp(n)) d--;
    n++;
  }
  cout << --n << '\n';
  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 rev(int x) {
  int ans = 0;
  while (x) {
    ans *= 10;
    ans += x % 10;
    x /= 10;
  }
  return ans;
}
bool is_prime(int n) {
  for (int i = 2; i * i <= n; ++i)
    if (n % i == 0) return false;
  return true;
}
bool emirp(int n) { return (n != rev(n) && is_prime(n) && is_prime(rev(n))); }
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int d;
  cin >> d;
  int n = 13;
  while (d) {
    if (emirp(n)) d--;
    n++;
  }
  cout << --n << '\n';
  return 0;
}

```