#include <bits/stdc++.h>
bool prime(int x) {
  int i;
  if (x == 1) return false;
  for (i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
int rev(int x) {
  int res = 0;
  while (x) {
    res = res * 10 + x % 10;
    x /= 10;
  }
  return res;
}
int main() {
  int i = 2, j;
  scanf("%d", &j);
  while (j) {
    if (prime(i) && prime(rev(i)) && i != rev(i)) j--;
    i++;
  }
  printf("%d", i - 1);
}

### 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>
bool prime(int x) {
  int i;
  if (x == 1) return false;
  for (i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
int rev(int x) {
  int res = 0;
  while (x) {
    res = res * 10 + x % 10;
    x /= 10;
  }
  return res;
}
int main() {
  int i = 2, j;
  scanf("%d", &j);
  while (j) {
    if (prime(i) && prime(rev(i)) && i != rev(i)) j--;
    i++;
  }
  printf("%d", i - 1);
}

```