#include <bits/stdc++.h>
using namespace std;
int rev(int n) {
  int r = 0;
  while (n) {
    r = 10 * r + n % 10;
    n /= 10;
  }
  return r;
}
int main() {
  const int N = 1000000;
  vector<bool> a(N + 1);
  for (int i = 2; i * i <= N; ++i)
    if (!a[i]) {
      for (int j = i * i; j <= N; j += i) a[j] = true;
    }
  vector<int> emirp;
  for (int i = 2; i <= N; ++i)
    if (!a[i]) {
      int r = rev(i);
      if (i != r && !a[r]) emirp.push_back(i);
    }
  int n;
  cin >> n;
  cout << emirp[n - 1] << endl;
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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 rev(int n) {
  int r = 0;
  while (n) {
    r = 10 * r + n % 10;
    n /= 10;
  }
  return r;
}
int main() {
  const int N = 1000000;
  vector<bool> a(N + 1);
  for (int i = 2; i * i <= N; ++i)
    if (!a[i]) {
      for (int j = i * i; j <= N; j += i) a[j] = true;
    }
  vector<int> emirp;
  for (int i = 2; i <= N; ++i)
    if (!a[i]) {
      int r = rev(i);
      if (i != r && !a[r]) emirp.push_back(i);
    }
  int n;
  cin >> n;
  cout << emirp[n - 1] << endl;
}

```