#include <bits/stdc++.h>
using namespace std;
int n, m, a[1000000], i, b[1000000];
int revert(int m) {
  int idx = 0;
  while (m > 0) {
    idx *= 10;
    idx += (m % 10);
    m /= 10;
  }
  return idx;
}
int main() {
  int w = 1;
  cin >> n;
  for (int i = 2; i <= 1000000; i++) {
    for (int j = 2 * i; j <= 1000000; j += i) {
      a[j] = 1;
    }
  }
  for (int i = 13; i <= 1000000; i++) {
    if (a[i] == 0 && a[revert(i)] == 0 && i != (revert(i))) {
      b[w] = i;
      w++;
    }
  }
  cout << b[n] << endl;
}

### Prompt

Your task is to create 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;
int n, m, a[1000000], i, b[1000000];
int revert(int m) {
  int idx = 0;
  while (m > 0) {
    idx *= 10;
    idx += (m % 10);
    m /= 10;
  }
  return idx;
}
int main() {
  int w = 1;
  cin >> n;
  for (int i = 2; i <= 1000000; i++) {
    for (int j = 2 * i; j <= 1000000; j += i) {
      a[j] = 1;
    }
  }
  for (int i = 13; i <= 1000000; i++) {
    if (a[i] == 0 && a[revert(i)] == 0 && i != (revert(i))) {
      b[w] = i;
      w++;
    }
  }
  cout << b[n] << endl;
}

```