#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int rev(int x) {
  int res = 0;
  while (x) {
    res = (res * 10) + x % 10;
    x /= 10;
  }
  return res;
}
int sieve[1000111];
void init() {
  for (int i = (2), _b = (1000); i <= _b; i++)
    if (!sieve[i]) {
      int j = i * i;
      while (j <= 1000000) {
        sieve[j] = 1;
        j += i;
      }
    }
  sieve[1] = 1;
}
int main() {
  init();
  int n;
  cin >> n;
  int k = 0;
  for (int i = (2), _b = (1000000); i <= _b; i++)
    if (!sieve[i] && !sieve[rev(i)] && rev(i) != i) {
      k++;
      if (k == n) {
        cout << i << endl;
        return 0;
      }
    }
  return 0;
}

### Prompt

Your challenge is to write 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;
const double PI = acos(-1.0);
int rev(int x) {
  int res = 0;
  while (x) {
    res = (res * 10) + x % 10;
    x /= 10;
  }
  return res;
}
int sieve[1000111];
void init() {
  for (int i = (2), _b = (1000); i <= _b; i++)
    if (!sieve[i]) {
      int j = i * i;
      while (j <= 1000000) {
        sieve[j] = 1;
        j += i;
      }
    }
  sieve[1] = 1;
}
int main() {
  init();
  int n;
  cin >> n;
  int k = 0;
  for (int i = (2), _b = (1000000); i <= _b; i++)
    if (!sieve[i] && !sieve[rev(i)] && rev(i) != i) {
      k++;
      if (k == n) {
        cout << i << endl;
        return 0;
      }
    }
  return 0;
}

```