#include <bits/stdc++.h>
using namespace std;
int ob(int i) {
  int s = 0;
  while (i > 0) s = s * 10 + i % 10, i /= 10;
  return s;
}
bool f(int n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
int main() {
  int n, kol = 0;
  cin >> n;
  for (int i = 2;; i++) {
    if (f(i) && f(ob(i)) && i != ob(i)) kol++;
    if (kol == n) {
      cout << i;
      break;
    }
  }
  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 ob(int i) {
  int s = 0;
  while (i > 0) s = s * 10 + i % 10, i /= 10;
  return s;
}
bool f(int n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
int main() {
  int n, kol = 0;
  cin >> n;
  for (int i = 2;; i++) {
    if (f(i) && f(ob(i)) && i != ob(i)) kol++;
    if (kol == n) {
      cout << i;
      break;
    }
  }
  return 0;
}

```