#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
int main() {
  int d;
  cin >> d;
  int cnt = 0;
  const int n = 1000000;
  vector<int> est(n + 1, 1);
  for (int k = 2; k < n; k++) {
    if (est[k]) {
      for (int j = 2; k * j <= n; j++) {
        est[k * j] = 0;
      }
    }
  }
  int i;
  for (i = 2;; i++) {
    int k = i;
    int rev = 0;
    while (true) {
      rev += k % 10;
      k /= 10;
      if (k == 0) break;
      rev *= 10;
    }
    if (i != rev && est[i] && est[rev]) {
      cnt++;
      if (cnt == d) {
        break;
      }
    }
  }
  cout << i;
}

### Prompt

Create a solution in CPP for 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;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
int main() {
  int d;
  cin >> d;
  int cnt = 0;
  const int n = 1000000;
  vector<int> est(n + 1, 1);
  for (int k = 2; k < n; k++) {
    if (est[k]) {
      for (int j = 2; k * j <= n; j++) {
        est[k * j] = 0;
      }
    }
  }
  int i;
  for (i = 2;; i++) {
    int k = i;
    int rev = 0;
    while (true) {
      rev += k % 10;
      k /= 10;
      if (k == 0) break;
      rev *= 10;
    }
    if (i != rev && est[i] && est[rev]) {
      cnt++;
      if (cnt == d) {
        break;
      }
    }
  }
  cout << i;
}

```