#include <bits/stdc++.h>
using namespace std;
bool zs(int x) {
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return 0;
  }
  return 1;
}
int fz(int y) {
  int t = 0;
  while (y) {
    t = t * 10 + y % 10;
    y /= 10;
  }
  return t;
}
int main() {
  int n, s = 1, i = 13;
  cin >> n;
  if (n == 1) {
    cout << 13;
    return 0;
  }
  while (1) {
    i++;
    int t = fz(i);
    if (zs(i) && zs(t) && i != t) {
      s++;
      if (s == n) {
        cout << i;
        return 0;
      }
    }
  }
  return 0;
}

### Prompt

Please provide a CPP coded solution 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>
using namespace std;
bool zs(int x) {
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return 0;
  }
  return 1;
}
int fz(int y) {
  int t = 0;
  while (y) {
    t = t * 10 + y % 10;
    y /= 10;
  }
  return t;
}
int main() {
  int n, s = 1, i = 13;
  cin >> n;
  if (n == 1) {
    cout << 13;
    return 0;
  }
  while (1) {
    i++;
    int t = fz(i);
    if (zs(i) && zs(t) && i != t) {
      s++;
      if (s == n) {
        cout << i;
        return 0;
      }
    }
  }
  return 0;
}

```