#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
inline int read() {
  int x = 0, neg = 1;
  char op = getchar();
  while (!isdigit(op)) {
    if (op == '-') neg = -1;
    op = getchar();
  }
  while (isdigit(op)) {
    x = 10 * x + op - '0';
    op = getchar();
  }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
const int N = 1000002;
vector<int> pr;
int vis[N];
void pre(int n) {
  vis[0] = vis[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!vis[i]) pr.push_back(i);
    for (auto v : pr) {
      if (i * v > n) break;
      vis[v * i] = 1;
      if (i % v == 0) break;
    }
  }
}
int rev(int x) {
  int y = 0;
  while (x > 0) {
    y = 10 * y + x % 10;
    x /= 10;
  }
  return y;
}
int n;
int main() {
  pre(1e6);
  scanf("%d", &n);
  for (register int i = 2;; i++) {
    if (!vis[i] && !vis[rev(i)] && rev(i) != i) {
      n--;
      if (n == 0) {
        printf("%d\n", i);
        exit(0);
      }
    }
  }
}

### Prompt

Create a solution in CPP for 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>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
inline int read() {
  int x = 0, neg = 1;
  char op = getchar();
  while (!isdigit(op)) {
    if (op == '-') neg = -1;
    op = getchar();
  }
  while (isdigit(op)) {
    x = 10 * x + op - '0';
    op = getchar();
  }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
const int N = 1000002;
vector<int> pr;
int vis[N];
void pre(int n) {
  vis[0] = vis[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!vis[i]) pr.push_back(i);
    for (auto v : pr) {
      if (i * v > n) break;
      vis[v * i] = 1;
      if (i % v == 0) break;
    }
  }
}
int rev(int x) {
  int y = 0;
  while (x > 0) {
    y = 10 * y + x % 10;
    x /= 10;
  }
  return y;
}
int n;
int main() {
  pre(1e6);
  scanf("%d", &n);
  for (register int i = 2;; i++) {
    if (!vis[i] && !vis[rev(i)] && rev(i) != i) {
      n--;
      if (n == 0) {
        printf("%d\n", i);
        exit(0);
      }
    }
  }
}

```