#include <bits/stdc++.h>
int T[1000000] = {1, 1};
int rev(int n) {
  int r = 0;
  for (; n;) {
    r = r * 10 + n % 10;
    n /= 10;
  }
  return r;
}
int main() {
  int i = 1, j, n;
  for (scanf("%d", &n); ++i <= 1000000;)
    if (!T[i])
      for (j = i + i; j <= 1000000; j += i) T[j] = 1;
  for (i = 2; i <= 1000000; i++)
    if (!T[i]) {
      j = rev(i);
      if (j != i && !T[j] && !--n) {
        printf("%d\n", i);
        return 0;
      }
    }
}

### Prompt

Your challenge is to write a Cpp solution 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>
int T[1000000] = {1, 1};
int rev(int n) {
  int r = 0;
  for (; n;) {
    r = r * 10 + n % 10;
    n /= 10;
  }
  return r;
}
int main() {
  int i = 1, j, n;
  for (scanf("%d", &n); ++i <= 1000000;)
    if (!T[i])
      for (j = i + i; j <= 1000000; j += i) T[j] = 1;
  for (i = 2; i <= 1000000; i++)
    if (!T[i]) {
      j = rev(i);
      if (j != i && !T[j] && !--n) {
        printf("%d\n", i);
        return 0;
      }
    }
}

```