#include <bits/stdc++.h>
using namespace std;
void make_primes(int n, vector<int>& v) {
  char* p = (char*)malloc(n + 1);
  memset(p, 0, sizeof(char) * (n + 1));
  v.push_back(2);
  for (int i = 3; i <= n; i += 2) {
    if (p[i] == 0) {
      v.push_back(i);
      for (int j = i + i; j <= n; j += i) p[j] = 1;
    }
  }
  free(p);
}
int rev(int n) {
  int x = 0;
  while (n > 0) {
    x = 10 * x + (n % 10);
    n /= 10;
  }
  return x;
}
int calc(int n, vector<int>& primes) {
  int p = 0;
  for (int i = 0; i < (int)(primes.size()); i++) {
    int r = rev(primes[i]);
    if (r == primes[i]) continue;
    if (binary_search(primes.begin(), primes.end(), r)) {
      ++p;
      if (p == n) return primes[i];
    }
  }
  assert(false);
  return -1;
}
int main() {
  vector<int> primes;
  make_primes(1000000, primes);
  int n;
  scanf("%d", &n);
  printf("%d\n", calc(n, primes));
}

### Prompt

Please create a solution in cpp 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;
void make_primes(int n, vector<int>& v) {
  char* p = (char*)malloc(n + 1);
  memset(p, 0, sizeof(char) * (n + 1));
  v.push_back(2);
  for (int i = 3; i <= n; i += 2) {
    if (p[i] == 0) {
      v.push_back(i);
      for (int j = i + i; j <= n; j += i) p[j] = 1;
    }
  }
  free(p);
}
int rev(int n) {
  int x = 0;
  while (n > 0) {
    x = 10 * x + (n % 10);
    n /= 10;
  }
  return x;
}
int calc(int n, vector<int>& primes) {
  int p = 0;
  for (int i = 0; i < (int)(primes.size()); i++) {
    int r = rev(primes[i]);
    if (r == primes[i]) continue;
    if (binary_search(primes.begin(), primes.end(), r)) {
      ++p;
      if (p == n) return primes[i];
    }
  }
  assert(false);
  return -1;
}
int main() {
  vector<int> primes;
  make_primes(1000000, primes);
  int n;
  scanf("%d", &n);
  printf("%d\n", calc(n, primes));
}

```