#include <bits/stdc++.h>
using namespace std;
bool ss(int n) {
  if (n <= 1) return 0;
  int i = 2;
  while (i * i <= n && n % i != 0) i++;
  return (i * i > n ? 1 : 0);
}
int re(int n) {
  int m = n, s = 0;
  while (n > 0) {
    s = s * 10 + n % 10;
    n /= 10;
  }
  return (s != m ? s : 1);
}
int main() {
  int n, a = 1, l = 0;
  cin >> n;
  while (l < n) {
    ++a;
    if (ss(a) && ss(re(a))) {
      l++;
    }
  }
  cout << a << endl;
  return 0;
}

### Prompt

Please create a solution in CPP 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 ss(int n) {
  if (n <= 1) return 0;
  int i = 2;
  while (i * i <= n && n % i != 0) i++;
  return (i * i > n ? 1 : 0);
}
int re(int n) {
  int m = n, s = 0;
  while (n > 0) {
    s = s * 10 + n % 10;
    n /= 10;
  }
  return (s != m ? s : 1);
}
int main() {
  int n, a = 1, l = 0;
  cin >> n;
  while (l < n) {
    ++a;
    if (ss(a) && ss(re(a))) {
      l++;
    }
  }
  cout << a << endl;
  return 0;
}

```