#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int N = 31623;
int l = 0;
int *a = new int[N];
void pri() {
  a[l++] = 2;
  for (int j = 3; j < N; j += 2) {
    bool pr = true;
    for (int i = 0; i < l; i++) {
      if (j % a[i] == 0) {
        pr = false;
        break;
      }
    }
    if (pr) a[l++] = j;
  }
}
bool isprime(int x) {
  for (int i = 0; i < l; ++i) {
    if (a[i] * a[i] > x) return true;
    if (x % a[i] == 0) return false;
  }
  return true;
}
int getz(int a) {
  int k = 0;
  while (a > 0) {
    k *= 10;
    k += a % 10;
    a /= 10;
  }
  return k;
}
int main() {
  ios::sync_with_stdio(0);
  pri();
  int n;
  cin >> n;
  for (int i = 13;; i += 2) {
    int k = getz(i);
    if (i != k && isprime(i) && isprime(k) && --n == 0) {
      cout << i;
      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 long long mod = 1e9 + 7;
int N = 31623;
int l = 0;
int *a = new int[N];
void pri() {
  a[l++] = 2;
  for (int j = 3; j < N; j += 2) {
    bool pr = true;
    for (int i = 0; i < l; i++) {
      if (j % a[i] == 0) {
        pr = false;
        break;
      }
    }
    if (pr) a[l++] = j;
  }
}
bool isprime(int x) {
  for (int i = 0; i < l; ++i) {
    if (a[i] * a[i] > x) return true;
    if (x % a[i] == 0) return false;
  }
  return true;
}
int getz(int a) {
  int k = 0;
  while (a > 0) {
    k *= 10;
    k += a % 10;
    a /= 10;
  }
  return k;
}
int main() {
  ios::sync_with_stdio(0);
  pri();
  int n;
  cin >> n;
  for (int i = 13;; i += 2) {
    int k = getz(i);
    if (i != k && isprime(i) && isprime(k) && --n == 0) {
      cout << i;
      return 0;
    }
  }
  return 0;
}

```