#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double PI = acos(-1);
const double EPS = 1e-8;
const int N = 1000000;
int prime[N];
int main() {
  for (int i = 0; i < (int)N; ++i) prime[i] = 1;
  prime[0] = prime[1] = 0;
  for (int i = 0; i < (int)N; ++i)
    if (prime[i])
      for (int j = i * 2; j < N; j += i) prime[j] = 0;
  vector<int> v;
  for (int i = 0; i < (int)N; ++i)
    if (prime[i]) {
      stringstream ss;
      ss << i;
      string s = ss.str();
      reverse((s).begin(), (s).end());
      stringstream tt(s);
      int j;
      tt >> j;
      if (i == j) continue;
      if (prime[j]) v.push_back(i);
    }
  int a;
  cin >> a;
  cout << v[a - 1] << endl;
}

### Prompt

Please formulate 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;
const int INF = 1 << 29;
const double PI = acos(-1);
const double EPS = 1e-8;
const int N = 1000000;
int prime[N];
int main() {
  for (int i = 0; i < (int)N; ++i) prime[i] = 1;
  prime[0] = prime[1] = 0;
  for (int i = 0; i < (int)N; ++i)
    if (prime[i])
      for (int j = i * 2; j < N; j += i) prime[j] = 0;
  vector<int> v;
  for (int i = 0; i < (int)N; ++i)
    if (prime[i]) {
      stringstream ss;
      ss << i;
      string s = ss.str();
      reverse((s).begin(), (s).end());
      stringstream tt(s);
      int j;
      tt >> j;
      if (i == j) continue;
      if (prime[j]) v.push_back(i);
    }
  int a;
  cin >> a;
  cout << v[a - 1] << endl;
}

```