#include <bits/stdc++.h>
using namespace std;
int n;
bool prime(int a) {
  for (int i = 2; i * i <= a; i++)
    if (a % i == 0) return false;
  return true;
}
bool ok(int a) {
  string s = to_string(a);
  reverse(s.begin(), s.end());
  return prime(a) && a != stoi(s) && prime(stoi(s));
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (int i = 2;; i++) {
    if (ok(i)) n--;
    if (n == 0) {
      cout << i;
      return 0;
    }
  }
  return 0;
}

### Prompt

Generate 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;
bool prime(int a) {
  for (int i = 2; i * i <= a; i++)
    if (a % i == 0) return false;
  return true;
}
bool ok(int a) {
  string s = to_string(a);
  reverse(s.begin(), s.end());
  return prime(a) && a != stoi(s) && prime(stoi(s));
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (int i = 2;; i++) {
    if (ok(i)) n--;
    if (n == 0) {
      cout << i;
      return 0;
    }
  }
  return 0;
}

```