#include <bits/stdc++.h>
using namespace std;
int rev(int c) {
  int rez = 0;
  while (c) {
    rez = rez * 10 + (c % 10);
    c /= 10;
  }
  return rez;
}
int main() {
  int x;
  cin >> x;
  int n = 10000005;
  vector<char> prime(n + 1, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i <= n; ++i)
    if (prime[i])
      if (i * 1ll * i <= n)
        for (int j = i * i; j <= n; j += i) prime[j] = false;
  int ans = 0;
  for (int i = 10; i < n; i++) {
    int f = rev(i);
    if (prime[i] && prime[f] && i != f) {
      ans++;
      if (ans == x) {
        cout << i;
        return 0;
      }
    }
  }
  return 0;
}

### 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;
int rev(int c) {
  int rez = 0;
  while (c) {
    rez = rez * 10 + (c % 10);
    c /= 10;
  }
  return rez;
}
int main() {
  int x;
  cin >> x;
  int n = 10000005;
  vector<char> prime(n + 1, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i <= n; ++i)
    if (prime[i])
      if (i * 1ll * i <= n)
        for (int j = i * i; j <= n; j += i) prime[j] = false;
  int ans = 0;
  for (int i = 10; i < n; i++) {
    int f = rev(i);
    if (prime[i] && prime[f] && i != f) {
      ans++;
      if (ans == x) {
        cout << i;
        return 0;
      }
    }
  }
  return 0;
}

```