#include <bits/stdc++.h>
using namespace std;
bool is_prime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return (x > 1);
}
int32_t main() {
  int n, x = 1;
  cin >> n;
  for (int i = 2;; i++) {
    if (!is_prime(i)) continue;
    string s = to_string(i);
    reverse(s.begin(), s.end());
    int b = stoi(s);
    if (b != i && is_prime(b)) {
      if (x == n) {
        cout << i;
        return 0;
      } else {
        x++;
      }
    }
  }
}

### 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;
bool is_prime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return (x > 1);
}
int32_t main() {
  int n, x = 1;
  cin >> n;
  for (int i = 2;; i++) {
    if (!is_prime(i)) continue;
    string s = to_string(i);
    reverse(s.begin(), s.end());
    int b = stoi(s);
    if (b != i && is_prime(b)) {
      if (x == n) {
        cout << i;
        return 0;
      } else {
        x++;
      }
    }
  }
}

```