#include <bits/stdc++.h>
using namespace std;
bool is_prime(long long n) {
  int i;
  for (i = 2; i <= sqrt(n); ++i)
    if (n % i == 0) return 0;
  return 1;
}
long long rev(long long n) {
  int ans = 0;
  while (n) {
    ans = ans * 10 + n % 10;
    n /= 10;
  }
  return ans;
}
long long a[11190];
int main() {
  int n, i, cnt = 1, x;
  for (i = 13; i; ++i) {
    if (is_prime(i)) {
      x = rev(i);
      if (is_prime(x) && x != i) a[cnt++] = i;
    }
    if (cnt == 11185) break;
  }
  cin >> n;
  cout << a[n] << endl;
  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;
bool is_prime(long long n) {
  int i;
  for (i = 2; i <= sqrt(n); ++i)
    if (n % i == 0) return 0;
  return 1;
}
long long rev(long long n) {
  int ans = 0;
  while (n) {
    ans = ans * 10 + n % 10;
    n /= 10;
  }
  return ans;
}
long long a[11190];
int main() {
  int n, i, cnt = 1, x;
  for (i = 13; i; ++i) {
    if (is_prime(i)) {
      x = rev(i);
      if (is_prime(x) && x != i) a[cnt++] = i;
    }
    if (cnt == 11185) break;
  }
  cin >> n;
  cout << a[n] << endl;
  return 0;
}

```