#include <bits/stdc++.h>
using namespace std;
bool prime[10000000];
int cnt, n;
int rev(int a) {
  int res = 0;
  while (a > 0) {
    res *= 10;
    res += (a % 10);
    a /= 10;
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < 10000000; i++) {
    prime[i] = true;
  }
  for (int i = 2; i < 10000000; i++) {
    if (prime[i]) {
      for (int j = i + i; j < 10000000; j += i) {
        prime[j] = false;
      }
    }
  }
  for (int i = 2; i < 10000000; i++) {
    if (prime[i] && prime[rev(i)] && i != rev(i)) {
      cnt++;
    }
    if (cnt == n) {
      cout << i;
      return 0;
    }
  }
  return 0;
}

### Prompt

Your task is to create 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;
bool prime[10000000];
int cnt, n;
int rev(int a) {
  int res = 0;
  while (a > 0) {
    res *= 10;
    res += (a % 10);
    a /= 10;
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < 10000000; i++) {
    prime[i] = true;
  }
  for (int i = 2; i < 10000000; i++) {
    if (prime[i]) {
      for (int j = i + i; j < 10000000; j += i) {
        prime[j] = false;
      }
    }
  }
  for (int i = 2; i < 10000000; i++) {
    if (prime[i] && prime[rev(i)] && i != rev(i)) {
      cnt++;
    }
    if (cnt == n) {
      cout << i;
      return 0;
    }
  }
  return 0;
}

```