#include <bits/stdc++.h>
using namespace std;
bool b[1000000] = {};
int main() {
  int n, w = 0, q = 0, k = 0, m = 1;
  cin >> n;
  for (int i = 2; i < 1000000; i++) {
    if (b[i] == 0)
      for (int j = i + i; j < 1000000; j += i) b[j] = 1;
  }
  for (int i = 13; i < 1000000; i++) {
    if (b[i] == 0) {
      w = 0;
      q = i;
      while (q > 0) {
        w = w * 10 + q % 10;
        q /= 10;
      }
      if (w != i && b[w] == 0) k++;
      if (k == n) {
        cout << i;
        return 0;
      }
    }
  }
  return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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 b[1000000] = {};
int main() {
  int n, w = 0, q = 0, k = 0, m = 1;
  cin >> n;
  for (int i = 2; i < 1000000; i++) {
    if (b[i] == 0)
      for (int j = i + i; j < 1000000; j += i) b[j] = 1;
  }
  for (int i = 13; i < 1000000; i++) {
    if (b[i] == 0) {
      w = 0;
      q = i;
      while (q > 0) {
        w = w * 10 + q % 10;
        q /= 10;
      }
      if (w != i && b[w] == 0) k++;
      if (k == n) {
        cout << i;
        return 0;
      }
    }
  }
  return 0;
}

```