#include <bits/stdc++.h>
using namespace std;
bool p[1000000];
int an[1000000], cnt;
int reverse(int x) {
  int res = 0;
  while (x) {
    res *= 10;
    res += x % 10;
    x /= 10;
  }
  return res;
}
int main() {
  int i, j, k, n, aa;
  for (i = 2; i * i < 1000000; i++) {
    if (!p[i])
      for (j = i + i; j < 1000000; j += i) p[j] = 1;
  }
  for (i = 2; i < 1000000; i++) {
    int tmp = reverse(i);
    if (i == tmp) continue;
    if (!p[i] && !p[reverse(i)]) an[++cnt] = i;
  }
  cin >> n;
  cout << an[n] << endl;
  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 p[1000000];
int an[1000000], cnt;
int reverse(int x) {
  int res = 0;
  while (x) {
    res *= 10;
    res += x % 10;
    x /= 10;
  }
  return res;
}
int main() {
  int i, j, k, n, aa;
  for (i = 2; i * i < 1000000; i++) {
    if (!p[i])
      for (j = i + i; j < 1000000; j += i) p[j] = 1;
  }
  for (i = 2; i < 1000000; i++) {
    int tmp = reverse(i);
    if (i == tmp) continue;
    if (!p[i] && !p[reverse(i)]) an[++cnt] = i;
  }
  cin >> n;
  cout << an[n] << endl;
  return 0;
}

```