#include <bits/stdc++.h>
using namespace std;
int d;
int sum = 0;
int r;
int s;
const int N = 1 << 25;
bool prime[(N - 3) / 2 + 1];
int reverse(int n) {
  int temp;
  int sum[20] = {0};
  int point = -1;
  temp = n;
  while (temp > 0) {
    point++;
    sum[point] = temp % 10;
    temp = temp / 10;
  }
  temp = 0;
  for (int(i) = (0); (i) < (point + 1); (i)++) {
    temp = temp * 10;
    temp += sum[i];
  }
  return temp;
}
void initPrime_f() {
  int i, j, T = (sqrt((double)N) - 3) / 2, C = (N - 3) / 2;
  memset(prime, 1, sizeof(prime));
  for (i = 0; i <= T; ++i) {
    if (prime[i]) {
      for (j = i * (2 * i + 6) + 3; j < C; j += i * 2 + 3) {
        prime[j] = false;
      }
    }
  }
}
bool isPrime(int N) {
  if (N == 2)
    return true;
  else if (N % 2 == 0)
    return false;
  else
    return prime[(N - 3) / 2];
}
int main(int argc, const char* argv[]) {
  scanf("%d", &d);
  initPrime_f();
  r = 2;
  while (1) {
    int s;
    s = reverse(r);
    if (isPrime(r) == true && isPrime(s) == true && r != s) {
      sum++;
    }
    if (sum == d) {
      printf("%d\n", r);
      break;
    }
    r++;
  }
  return 0;
}

### Prompt

Please formulate 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>
using namespace std;
int d;
int sum = 0;
int r;
int s;
const int N = 1 << 25;
bool prime[(N - 3) / 2 + 1];
int reverse(int n) {
  int temp;
  int sum[20] = {0};
  int point = -1;
  temp = n;
  while (temp > 0) {
    point++;
    sum[point] = temp % 10;
    temp = temp / 10;
  }
  temp = 0;
  for (int(i) = (0); (i) < (point + 1); (i)++) {
    temp = temp * 10;
    temp += sum[i];
  }
  return temp;
}
void initPrime_f() {
  int i, j, T = (sqrt((double)N) - 3) / 2, C = (N - 3) / 2;
  memset(prime, 1, sizeof(prime));
  for (i = 0; i <= T; ++i) {
    if (prime[i]) {
      for (j = i * (2 * i + 6) + 3; j < C; j += i * 2 + 3) {
        prime[j] = false;
      }
    }
  }
}
bool isPrime(int N) {
  if (N == 2)
    return true;
  else if (N % 2 == 0)
    return false;
  else
    return prime[(N - 3) / 2];
}
int main(int argc, const char* argv[]) {
  scanf("%d", &d);
  initPrime_f();
  r = 2;
  while (1) {
    int s;
    s = reverse(r);
    if (isPrime(r) == true && isPrime(s) == true && r != s) {
      sum++;
    }
    if (sum == d) {
      printf("%d\n", r);
      break;
    }
    r++;
  }
  return 0;
}

```