#include <bits/stdc++.h>
using namespace std;
int coun = 0;
int prime[1000001] = {0};
void shai() {
  coun = 1;
  prime[1] = 2;
  for (int i = 3;; i++) {
    if (coun == 200000) return;
    if (!(i % 2)) continue;
    int can = 1;
    for (int j = 1; prime[j] <= sqrt(i); j++) {
      if (i % prime[j] == 0) {
        can = 0;
        break;
      }
    }
    if (can) prime[++coun] = i;
  }
}
bool isprime(int n) {
  for (int i = 2; i <= sqrt(n); i++)
    if (!(n % i)) return 0;
  return 1;
}
bool check(int k) {
  int c = 0;
  int t = k;
  while (t) {
    t /= 10;
    c++;
  }
  int temp = 1;
  for (int i = 0; i < c - 1; i++) temp *= 10;
  t = 0;
  int x = k;
  while (x) {
    t += (x % 10) * temp;
    x /= 10;
    temp /= 10;
  }
  if (isprime(t) && t != k) return 1;
  return 0;
}
int main() {
  shai();
  int n;
  cin >> n;
  int x = 0;
  for (int i = 1; i <= 1000000; i++) {
    if (check(prime[i])) x++;
    if (x == n) {
      cout << prime[i] << endl;
      return 0;
    }
  }
}

### Prompt

In CPP, your task is to solve 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;
int coun = 0;
int prime[1000001] = {0};
void shai() {
  coun = 1;
  prime[1] = 2;
  for (int i = 3;; i++) {
    if (coun == 200000) return;
    if (!(i % 2)) continue;
    int can = 1;
    for (int j = 1; prime[j] <= sqrt(i); j++) {
      if (i % prime[j] == 0) {
        can = 0;
        break;
      }
    }
    if (can) prime[++coun] = i;
  }
}
bool isprime(int n) {
  for (int i = 2; i <= sqrt(n); i++)
    if (!(n % i)) return 0;
  return 1;
}
bool check(int k) {
  int c = 0;
  int t = k;
  while (t) {
    t /= 10;
    c++;
  }
  int temp = 1;
  for (int i = 0; i < c - 1; i++) temp *= 10;
  t = 0;
  int x = k;
  while (x) {
    t += (x % 10) * temp;
    x /= 10;
    temp /= 10;
  }
  if (isprime(t) && t != k) return 1;
  return 0;
}
int main() {
  shai();
  int n;
  cin >> n;
  int x = 0;
  for (int i = 1; i <= 1000000; i++) {
    if (check(prime[i])) x++;
    if (x == n) {
      cout << prime[i] << endl;
      return 0;
    }
  }
}

```