#include <bits/stdc++.h>
using namespace std;
long long inv(long long a) {
  long long r;
  for (r = 0; a > 0; a /= 10) r = r * 10 + (a % 10);
  return r;
}
bool simp(long long n) {
  long long i;
  for (i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return 0;
  return 1;
}
int main() {
  long long n, i, j;
  cin >> n;
  for (i = 10, j = 0; j < n; i++)
    if (simp(i) && simp(inv(i)) && i != inv(i)) j++;
  cout << i - 1;
  return 0;
}

### Prompt

Your task is to create 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;
long long inv(long long a) {
  long long r;
  for (r = 0; a > 0; a /= 10) r = r * 10 + (a % 10);
  return r;
}
bool simp(long long n) {
  long long i;
  for (i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return 0;
  return 1;
}
int main() {
  long long n, i, j;
  cin >> n;
  for (i = 10, j = 0; j < n; i++)
    if (simp(i) && simp(inv(i)) && i != inv(i)) j++;
  cout << i - 1;
  return 0;
}

```