#include <bits/stdc++.h>
using namespace std;
bool f[1000005];
char s[10];
int rev(int x) {
  int y;
  sprintf(s, "%d", x);
  reverse(s, s + strlen(s));
  sscanf(s, "%d", &y);
  return y;
}
void work() {
  int i, j, sum = 0, n;
  cin >> n;
  for (i = 2; i * i <= 1000000; ++i)
    if (!f[i])
      for (j = i * i; j <= 1000000; j += i) f[j] = 1;
  f[0] = f[1] = 1;
  for (i = 10; i <= 1000000; ++i)
    if (!f[i]) {
      j = rev(i);
      if (i != j && !f[j]) ++sum;
      if (sum == n) break;
    }
  cout << i;
}
int main() {
  work();
  return 0;
}

### Prompt

Generate 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;
bool f[1000005];
char s[10];
int rev(int x) {
  int y;
  sprintf(s, "%d", x);
  reverse(s, s + strlen(s));
  sscanf(s, "%d", &y);
  return y;
}
void work() {
  int i, j, sum = 0, n;
  cin >> n;
  for (i = 2; i * i <= 1000000; ++i)
    if (!f[i])
      for (j = i * i; j <= 1000000; j += i) f[j] = 1;
  f[0] = f[1] = 1;
  for (i = 10; i <= 1000000; ++i)
    if (!f[i]) {
      j = rev(i);
      if (i != j && !f[j]) ++sum;
      if (sum == n) break;
    }
  cout << i;
}
int main() {
  work();
  return 0;
}

```