#include <bits/stdc++.h>
using namespace std;
bool prime(int n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  for (int i = 3; i <= sqrt(n); i++)
    if (n % i == 0) return false;
  return true;
}
int rev(int n) {
  int b = 0;
  while (n) {
    b *= 10;
    b += n % 10;
    n = n / 10;
  }
  return b;
}
int main() {
  int n;
  cin >> n;
  int i = 0;
  int k = 10;
  while (i < n) {
    if (prime(k) && prime(rev(k)) && k != rev(k)) i++;
    k++;
  }
  cout << k - 1 << endl;
}

### 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;
bool prime(int n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  for (int i = 3; i <= sqrt(n); i++)
    if (n % i == 0) return false;
  return true;
}
int rev(int n) {
  int b = 0;
  while (n) {
    b *= 10;
    b += n % 10;
    n = n / 10;
  }
  return b;
}
int main() {
  int n;
  cin >> n;
  int i = 0;
  int k = 10;
  while (i < n) {
    if (prime(k) && prime(rev(k)) && k != rev(k)) i++;
    k++;
  }
  cout << k - 1 << endl;
}

```