#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> primeTable(1000000, 1);
  primeTable[0] = primeTable[1] = 0;
  for (int i = 2; i < 1000000; i++) {
    if (primeTable[i] == 0) {
      continue;
    }
    for (int j = 2 * i; j < 1000000; j += i) {
      primeTable[j] = 0;
    }
  }
  int count = 0;
  for (int i = 1; i < 1000000; i++) {
    if (primeTable[i] == 1) {
      int hoge;
      string conv;
      stringstream in;
      stringstream out;
      in << i;
      conv = in.str();
      reverse(conv.begin(), conv.end());
      out << conv;
      out >> hoge;
      if (i != hoge && primeTable[hoge] == 1) {
        count++;
        if (count == n) {
          cout << i << endl;
          break;
        }
      }
    }
  }
  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;
int main() {
  int n;
  cin >> n;
  vector<int> primeTable(1000000, 1);
  primeTable[0] = primeTable[1] = 0;
  for (int i = 2; i < 1000000; i++) {
    if (primeTable[i] == 0) {
      continue;
    }
    for (int j = 2 * i; j < 1000000; j += i) {
      primeTable[j] = 0;
    }
  }
  int count = 0;
  for (int i = 1; i < 1000000; i++) {
    if (primeTable[i] == 1) {
      int hoge;
      string conv;
      stringstream in;
      stringstream out;
      in << i;
      conv = in.str();
      reverse(conv.begin(), conv.end());
      out << conv;
      out >> hoge;
      if (i != hoge && primeTable[hoge] == 1) {
        count++;
        if (count == n) {
          cout << i << endl;
          break;
        }
      }
    }
  }
  return 0;
}

```