#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
bool bad[N];
int reverse(int x) {
  int ret = 0;
  while (x) {
    ret = ret * 10 + x % 10;
    x /= 10;
  }
  return ret;
}
int main() {
  int n, i, j, a, b;
  bad[1] = true;
  for (i = 2; i * i <= N; i++) {
    if (bad[i]) continue;
    for (j = i * i; j < N; j += i) bad[j] = true;
  }
  cin >> n;
  string s;
  for (i = 2;; i++) {
    if (!bad[i]) {
      j = reverse(i);
      if (j != i && !bad[j]) --n;
      if (n == 0) {
        printf("%d\n", 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;
const int N = 1000000;
bool bad[N];
int reverse(int x) {
  int ret = 0;
  while (x) {
    ret = ret * 10 + x % 10;
    x /= 10;
  }
  return ret;
}
int main() {
  int n, i, j, a, b;
  bad[1] = true;
  for (i = 2; i * i <= N; i++) {
    if (bad[i]) continue;
    for (j = i * i; j < N; j += i) bad[j] = true;
  }
  cin >> n;
  string s;
  for (i = 2;; i++) {
    if (!bad[i]) {
      j = reverse(i);
      if (j != i && !bad[j]) --n;
      if (n == 0) {
        printf("%d\n", i);
        return 0;
      }
    }
  }
  return 0;
}

```