#include <bits/stdc++.h>
int asalmi(int x) {
  int i, k = (int)sqrt(x);
  for (i = 2; i <= k; i++)
    if (x % i == 0) return 0;
  return 1;
}
int ters(int x) {
  int bas = 0, t = x, i, k = 0;
  while (t) {
    bas++;
    t /= 10;
  }
  for (i = 1; i <= bas; i++) {
    k *= 10;
    k += x % 10;
    x /= 10;
  }
  return k;
}
using namespace std;
long long m, n;
void read() {
  int i = 10, j, say = 0;
  cin >> n;
  while (i++) {
    if (asalmi(i) && ters(i) != i && asalmi(ters(i))) {
      say++;
    }
    if (say == n) {
      cout << i;
      break;
    }
  }
}
void solve() { int i, j; }
void write() { int i, j; }
int main() {
  read();
  solve();
  write();
  return 0;
}

### Prompt

Develop a solution in cpp to the problem described below:

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>
int asalmi(int x) {
  int i, k = (int)sqrt(x);
  for (i = 2; i <= k; i++)
    if (x % i == 0) return 0;
  return 1;
}
int ters(int x) {
  int bas = 0, t = x, i, k = 0;
  while (t) {
    bas++;
    t /= 10;
  }
  for (i = 1; i <= bas; i++) {
    k *= 10;
    k += x % 10;
    x /= 10;
  }
  return k;
}
using namespace std;
long long m, n;
void read() {
  int i = 10, j, say = 0;
  cin >> n;
  while (i++) {
    if (asalmi(i) && ters(i) != i && asalmi(ters(i))) {
      say++;
    }
    if (say == n) {
      cout << i;
      break;
    }
  }
}
void solve() { int i, j; }
void write() { int i, j; }
int main() {
  read();
  solve();
  write();
  return 0;
}

```