#include <bits/stdc++.h>
using namespace std;
bool is_prime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (!(x % i)) return false;
  return x > 1;
}
int reverse(int x) {
  string s = "0";
  for (int i = x; i; i /= 10) s += '0' + i % 10;
  return stoi(s);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0;; i++)
    if (i ^ reverse(i) && is_prime(i) && is_prime(reverse(i)) && !--n)
      return cout << i, 0;
}

### Prompt

Construct a cpp code solution to the problem outlined:

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 is_prime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (!(x % i)) return false;
  return x > 1;
}
int reverse(int x) {
  string s = "0";
  for (int i = x; i; i /= 10) s += '0' + i % 10;
  return stoi(s);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0;; i++)
    if (i ^ reverse(i) && is_prime(i) && is_prime(reverse(i)) && !--n)
      return cout << i, 0;
}

```