#include <bits/stdc++.h>
using namespace std;
int dig[15];
int rev(int x) {
  int dd = 0;
  while (x) dig[++dd] = x % 10, x /= 10;
  x = 0;
  for (int i = 1; i <= dd; i++) x = x * 10 + dig[i];
  return x;
}
bool check(int x) {
  int xx = sqrt(x);
  for (int i = 2; i <= xx; i++)
    if (x % i == 0) return false;
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0, pr = 13;
  while (1) {
    int rp = rev(pr);
    if (check(pr) && check(rp) && pr != rp) cnt++;
    if (cnt == n) break;
    pr++;
  }
  printf("%d\n", pr);
  return 0;
}

### Prompt

In Cpp, your task is to solve 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 dig[15];
int rev(int x) {
  int dd = 0;
  while (x) dig[++dd] = x % 10, x /= 10;
  x = 0;
  for (int i = 1; i <= dd; i++) x = x * 10 + dig[i];
  return x;
}
bool check(int x) {
  int xx = sqrt(x);
  for (int i = 2; i <= xx; i++)
    if (x % i == 0) return false;
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0, pr = 13;
  while (1) {
    int rp = rev(pr);
    if (check(pr) && check(rp) && pr != rp) cnt++;
    if (cnt == n) break;
    pr++;
  }
  printf("%d\n", pr);
  return 0;
}

```