#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int N;
bool prime(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int rev(int n) {
  int m = 0;
  for (; n; n /= 10) {
    m = 10 * m + n % 10;
  }
  return m;
}
void solve() {
  int cnt = 0;
  for (int i = 2;; i++) {
    if (prime(i) && prime(rev(i)) && i != rev(i)) {
      cnt++;
      if (cnt == N) {
        cout << i << endl;
        return;
      }
    }
  }
}
int main() {
  while (cin >> N) {
    solve();
  }
}

### Prompt

Generate 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 double pi = acos(-1.0);
int N;
bool prime(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int rev(int n) {
  int m = 0;
  for (; n; n /= 10) {
    m = 10 * m + n % 10;
  }
  return m;
}
void solve() {
  int cnt = 0;
  for (int i = 2;; i++) {
    if (prime(i) && prime(rev(i)) && i != rev(i)) {
      cnt++;
      if (cnt == N) {
        cout << i << endl;
        return;
      }
    }
  }
}
int main() {
  while (cin >> N) {
    solve();
  }
}

```