#include <bits/stdc++.h>
using namespace std;
const int MAXX = 1e6 + 10;
int n;
bool ip[MAXX];
int r(int x) {
  int ans_r = 0;
  for (int i = 1; x / i > 0; i *= 10) ans_r *= 10, ans_r += (x / i) % 10;
  return ans_r;
}
void era() {
  ip[1] = true;
  for (int i = 2; i < MAXX; i++)
    if (!ip[i])
      for (int j = 2 * i; j < MAXX; j += i) ip[j] = true;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n, era();
  for (int i = 1; i < MAXX; i++) {
    if (!ip[i] && !ip[r(i)] && r(i) != i) n--;
    if (!n) return cout << i << endl, 0;
  }
}

### Prompt

Please formulate 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;
const int MAXX = 1e6 + 10;
int n;
bool ip[MAXX];
int r(int x) {
  int ans_r = 0;
  for (int i = 1; x / i > 0; i *= 10) ans_r *= 10, ans_r += (x / i) % 10;
  return ans_r;
}
void era() {
  ip[1] = true;
  for (int i = 2; i < MAXX; i++)
    if (!ip[i])
      for (int j = 2 * i; j < MAXX; j += i) ip[j] = true;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n, era();
  for (int i = 1; i < MAXX; i++) {
    if (!ip[i] && !ip[r(i)] && r(i) != i) n--;
    if (!n) return cout << i << endl, 0;
  }
}

```