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

### Prompt

Create a solution in Cpp for 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 a[1000001], i, j, k, t, ans, n, m;
int main() {
  cin >> n;
  for (i = 2; i <= 1000000; i++)
    if (!a[i])
      for (j = i + i; j <= 1000000; j += i) a[j] = 1;
  for (i = 2; i <= 1000000; i++) {
    if (a[i]) continue;
    j = i;
    t = 0;
    while (j > 0) {
      t = 10 * t + j % 10;
      j /= 10;
    }
    if (i != t && !a[t]) m++;
    if (m == n) {
      cout << i;
      return 0;
    }
  }
  return 0;
}

```