#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<bool> p(1000000, true);
  p[0] = false;
  p[1] = false;
  for (int i = 2; i < p.size(); i++) {
    if (!p[i]) continue;
    for (int j = 2; i * j < p.size(); j++) p[i * j] = false;
  }
  int i = 1;
  while (n) {
    if (p[i]) {
      int t = i;
      int r = 0;
      while (t > 0) {
        r = r * 10 + t % 10;
        t /= 10;
      }
      if (p[r] && r != i) {
        n--;
      }
    }
    i++;
  }
  cout << i - 1 << endl;
}

### Prompt

Your task is to create 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 main() {
  int n;
  cin >> n;
  vector<bool> p(1000000, true);
  p[0] = false;
  p[1] = false;
  for (int i = 2; i < p.size(); i++) {
    if (!p[i]) continue;
    for (int j = 2; i * j < p.size(); j++) p[i * j] = false;
  }
  int i = 1;
  while (n) {
    if (p[i]) {
      int t = i;
      int r = 0;
      while (t > 0) {
        r = r * 10 + t % 10;
        t /= 10;
      }
      if (p[r] && r != i) {
        n--;
      }
    }
    i++;
  }
  cout << i - 1 << endl;
}

```