#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int N = 1e6;
bool p[N];
vector<int32_t> ans;
int rev(int x) {
  int ans = 0;
  while (x > 0) {
    ans = 10 * ans + x % 10;
    x /= 10;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed;
  fill(p + 2, p + N, true);
  for (int i = 2; i < N; i++) {
    if (p[i]) {
      for (int j = i + i; j <= N; j += i) p[j] = false;
    }
  }
  for (int i = 13; i < N; i++) {
    if (p[i]) {
      int j = rev(i);
      if (i != j && p[j]) ans.push_back(i);
    }
  }
  int n;
  cin >> n;
  cout << ans[n - 1] << endl;
  return 0;
}

### Prompt

Please create a solution in Cpp 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;
using pii = pair<int, int>;
const int N = 1e6;
bool p[N];
vector<int32_t> ans;
int rev(int x) {
  int ans = 0;
  while (x > 0) {
    ans = 10 * ans + x % 10;
    x /= 10;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed;
  fill(p + 2, p + N, true);
  for (int i = 2; i < N; i++) {
    if (p[i]) {
      for (int j = i + i; j <= N; j += i) p[j] = false;
    }
  }
  for (int i = 13; i < N; i++) {
    if (p[i]) {
      int j = rev(i);
      if (i != j && p[j]) ans.push_back(i);
    }
  }
  int n;
  cin >> n;
  cout << ans[n - 1] << endl;
  return 0;
}

```