#include <bits/stdc++.h>
using namespace std;
inline bool iss(int v) {
  for (int i = 2; i * i <= v; i++)
    if (!(v % i)) return false;
  return true;
}
inline int inv(int v) {
  int res = 0;
  while (v) {
    res = 10 * res + v % 10;
    v /= 10;
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  int i = 1;
  while (n--) {
    do i++;
    while (!((i != inv(i)) && iss(i) && iss(inv(i))));
  }
  cout << i << endl;
  return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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 iss(int v) {
  for (int i = 2; i * i <= v; i++)
    if (!(v % i)) return false;
  return true;
}
inline int inv(int v) {
  int res = 0;
  while (v) {
    res = 10 * res + v % 10;
    v /= 10;
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  int i = 1;
  while (n--) {
    do i++;
    while (!((i != inv(i)) && iss(i) && iss(inv(i))));
  }
  cout << i << endl;
  return 0;
}

```