#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
bool prime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
int main() {
  int n;
  cin >> n;
  for (int i = 13;; i++)
    if (prime(i)) {
      stringstream st;
      st << i;
      string s;
      st >> s;
      reverse((s).begin(), (s).end());
      int l = atoi(s.c_str());
      if (prime(l) && l != i) {
        n--;
        if (n == 0) {
          cout << i << endl;
          return 0;
        }
      }
    }
  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>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
bool prime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
int main() {
  int n;
  cin >> n;
  for (int i = 13;; i++)
    if (prime(i)) {
      stringstream st;
      st << i;
      string s;
      st >> s;
      reverse((s).begin(), (s).end());
      int l = atoi(s.c_str());
      if (prime(l) && l != i) {
        n--;
        if (n == 0) {
          cout << i << endl;
          return 0;
        }
      }
    }
  return 0;
}

```