#include <bits/stdc++.h>
using namespace std;
inline bool pd(int x) {
  for (int i = 2; i <= sqrt(x); i++)
    if (x % i == 0) return 0;
  return 1;
}
inline bool w(int x) {
  if (!pd(x)) return 0;
  int n = x;
  int k = 0;
  while (x) {
    k = k * 10 + x % 10;
    x /= 10;
  }
  if (n == k) return 0;
  return pd(k);
}
int main() {
  int n, i;
  cin >> n;
  for (i = 13; n; i++)
    if (w(i)) --n;
  cout << i - 1 << 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;
inline bool pd(int x) {
  for (int i = 2; i <= sqrt(x); i++)
    if (x % i == 0) return 0;
  return 1;
}
inline bool w(int x) {
  if (!pd(x)) return 0;
  int n = x;
  int k = 0;
  while (x) {
    k = k * 10 + x % 10;
    x /= 10;
  }
  if (n == k) return 0;
  return pd(k);
}
int main() {
  int n, i;
  cin >> n;
  for (i = 13; n; i++)
    if (w(i)) --n;
  cout << i - 1 << endl;
  return 0;
}

```