#include <bits/stdc++.h>
using namespace std;
bitset<1000000> prime;
void IsPrime() {
  prime[0] = prime[1] = 0;
  prime[2] = 1;
  for (int i = 3; i < 1000000; i++) prime[i] = i % 2 == 0 ? 0 : 1;
  int t = (int)sqrt(1000000 * 1.0);
  for (int i = 3; i <= t; i++)
    if (prime[i]) {
      for (long long j = i * i; j < 1000000; j += 2 * i) prime[j] = 0;
    }
}
int rev(int num) {
  int ret = 0;
  vector<int> v;
  while (num) {
    v.push_back(num % 10);
    num /= 10;
  }
  int tmp = 1;
  for (int i = v.size() - 1; i >= 0; i--) {
    ret += tmp * v[i];
    tmp *= 10;
  }
  return ret;
}
int main() {
  IsPrime();
  vector<int> v;
  for (int i = 2; i < 1000000; i++) {
    if (prime[i]) {
      int re = rev(i);
      if (re != i && prime[re]) {
        v.push_back(i);
      }
    }
  }
  int n;
  scanf("%d", &n);
  printf("%d\n", v[n - 1]);
  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;
bitset<1000000> prime;
void IsPrime() {
  prime[0] = prime[1] = 0;
  prime[2] = 1;
  for (int i = 3; i < 1000000; i++) prime[i] = i % 2 == 0 ? 0 : 1;
  int t = (int)sqrt(1000000 * 1.0);
  for (int i = 3; i <= t; i++)
    if (prime[i]) {
      for (long long j = i * i; j < 1000000; j += 2 * i) prime[j] = 0;
    }
}
int rev(int num) {
  int ret = 0;
  vector<int> v;
  while (num) {
    v.push_back(num % 10);
    num /= 10;
  }
  int tmp = 1;
  for (int i = v.size() - 1; i >= 0; i--) {
    ret += tmp * v[i];
    tmp *= 10;
  }
  return ret;
}
int main() {
  IsPrime();
  vector<int> v;
  for (int i = 2; i < 1000000; i++) {
    if (prime[i]) {
      int re = rev(i);
      if (re != i && prime[re]) {
        v.push_back(i);
      }
    }
  }
  int n;
  scanf("%d", &n);
  printf("%d\n", v[n - 1]);
  return 0;
}

```