#include <bits/stdc++.h>
int prime[1000001];
int primelist[1000001];
int rev(int n) {
  int ans = 0;
  while (n) {
    ans = ans * 10 + (n % 10);
    n /= 10;
  }
  return ans;
}
int find_primes() {
  int cnt, i, j;
  for (i = 2; i < 1000001; i++)
    if (prime[i] == 0)
      for (j = 2 * i; j < 1000001; j += i) prime[j] = 1;
  for (cnt = 0, i = 2; i < 1000001; i++)
    if (prime[i] == 0) {
      int rvrs = rev(i);
      if (rvrs != i)
        if (prime[rvrs] == 0) primelist[cnt++] = i;
    }
  return cnt;
}
int main() {
  int n;
  find_primes();
  scanf("%d", &n);
  printf("%d\n", primelist[n - 1]);
  return 0;
}

### Prompt

In cpp, your task is to solve 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 prime[1000001];
int primelist[1000001];
int rev(int n) {
  int ans = 0;
  while (n) {
    ans = ans * 10 + (n % 10);
    n /= 10;
  }
  return ans;
}
int find_primes() {
  int cnt, i, j;
  for (i = 2; i < 1000001; i++)
    if (prime[i] == 0)
      for (j = 2 * i; j < 1000001; j += i) prime[j] = 1;
  for (cnt = 0, i = 2; i < 1000001; i++)
    if (prime[i] == 0) {
      int rvrs = rev(i);
      if (rvrs != i)
        if (prime[rvrs] == 0) primelist[cnt++] = i;
    }
  return cnt;
}
int main() {
  int n;
  find_primes();
  scanf("%d", &n);
  printf("%d\n", primelist[n - 1]);
  return 0;
}

```