#include <bits/stdc++.h>
int main() {
  bool a[999999];
  int c = 999999, d = 0, k = 0, n, p, rev(int);
  for (int i = 2; i < c; i++) a[i] = 1;
  for (int i = 2; i < c; i++)
    if (a[i])
      for (int j = 2 * i; j < c; j += i) a[j] = 0;
  scanf("%d", &n);
  while (k < n) {
    d++;
    if (a[d]) {
      p = rev(d);
      if (d != p && a[p]) k++;
    }
  }
  printf("%d", d);
  return 0;
}
int rev(int a) {
  int r = 0;
  while (a) {
    r = 10 * r + a % 10;
    a /= 10;
  }
  return r;
}

### 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>
int main() {
  bool a[999999];
  int c = 999999, d = 0, k = 0, n, p, rev(int);
  for (int i = 2; i < c; i++) a[i] = 1;
  for (int i = 2; i < c; i++)
    if (a[i])
      for (int j = 2 * i; j < c; j += i) a[j] = 0;
  scanf("%d", &n);
  while (k < n) {
    d++;
    if (a[d]) {
      p = rev(d);
      if (d != p && a[p]) k++;
    }
  }
  printf("%d", d);
  return 0;
}
int rev(int a) {
  int r = 0;
  while (a) {
    r = 10 * r + a % 10;
    a /= 10;
  }
  return r;
}

```