#include <bits/stdc++.h>
using namespace std;
int tot, n;
int prime[10000500];
bool ispri[10000500];
void init() {
  tot = 0;
  memset(ispri, true, sizeof(ispri));
  for (long long i = 2; i < 10000500; i++) {
    if (ispri[i]) {
      prime[tot++] = i;
      for (long long j = i * i; j < 10000500; j += i) ispri[j] = false;
    }
  }
}
bool check(int x) {
  int res = 0, tmp = x;
  while (tmp) {
    res *= 10;
    res += tmp % 10;
    tmp /= 10;
  }
  if (x != res && ispri[res]) return true;
  return false;
}
int main() {
  init();
  while (cin >> n) {
    for (int i = 0, cnt = 0; i < tot; i++) {
      if (check(prime[i])) cnt++;
      if (cnt == n) {
        cout << prime[i] << endl;
        break;
      }
    }
  }
  return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

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 tot, n;
int prime[10000500];
bool ispri[10000500];
void init() {
  tot = 0;
  memset(ispri, true, sizeof(ispri));
  for (long long i = 2; i < 10000500; i++) {
    if (ispri[i]) {
      prime[tot++] = i;
      for (long long j = i * i; j < 10000500; j += i) ispri[j] = false;
    }
  }
}
bool check(int x) {
  int res = 0, tmp = x;
  while (tmp) {
    res *= 10;
    res += tmp % 10;
    tmp /= 10;
  }
  if (x != res && ispri[res]) return true;
  return false;
}
int main() {
  init();
  while (cin >> n) {
    for (int i = 0, cnt = 0; i < tot; i++) {
      if (check(prime[i])) cnt++;
      if (cnt == n) {
        cout << prime[i] << endl;
        break;
      }
    }
  }
  return 0;
}

```