#include <bits/stdc++.h>
using namespace std;
int rev(int n) {
  int r = 0;
  while (n > 0) {
    r *= 10;
    r += (n % 10);
    n /= 10;
  }
  return r;
}
bool isSimp(int n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  int i = 3;
  while (i * i <= n) {
    if (n % i == 0) return false;
    i += 2;
  };
  return true;
}
int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  int i = 11;
  while (n > 0) {
    i += 2;
    int temp = rev(i);
    if ((i != temp) && (isSimp(i)) && isSimp(temp)) n--;
  };
  cout << i << endl;
  return 0;
}

### Prompt

Your challenge is to write 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;
int rev(int n) {
  int r = 0;
  while (n > 0) {
    r *= 10;
    r += (n % 10);
    n /= 10;
  }
  return r;
}
bool isSimp(int n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  int i = 3;
  while (i * i <= n) {
    if (n % i == 0) return false;
    i += 2;
  };
  return true;
}
int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  int i = 11;
  while (n > 0) {
    i += 2;
    int temp = rev(i);
    if ((i != temp) && (isSimp(i)) && isSimp(temp)) n--;
  };
  cout << i << endl;
  return 0;
}

```