#include <bits/stdc++.h>
using namespace std;
bool asal(int x) {
  int i;
  if (x == 1) return 0;
  for (i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
int cevir(int x) {
  int on = 10000000;
  int z, y = 0;
  z = x;
  while (z) {
    y += (z % 10) * on;
    on /= 10;
    z /= 10;
  }
  return y / (10 * on);
}
int main() {
  int n, i, s = 0;
  cin >> n;
  for (i = 1;; i++) {
    if (asal(i) && asal(cevir(i)) && i != cevir(i)) s++;
    if (s == n) {
      cout << i << endl;
      break;
    }
  }
  getchar();
  getchar();
  return 0;
}

### Prompt

Generate 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 asal(int x) {
  int i;
  if (x == 1) return 0;
  for (i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
int cevir(int x) {
  int on = 10000000;
  int z, y = 0;
  z = x;
  while (z) {
    y += (z % 10) * on;
    on /= 10;
    z /= 10;
  }
  return y / (10 * on);
}
int main() {
  int n, i, s = 0;
  cin >> n;
  for (i = 1;; i++) {
    if (asal(i) && asal(cevir(i)) && i != cevir(i)) s++;
    if (s == n) {
      cout << i << endl;
      break;
    }
  }
  getchar();
  getchar();
  return 0;
}

```