#include <bits/stdc++.h>
int prime[1000005];
int change(int b) {
  int s[50], tmp(0), cnt(0), sum(0);
  while (b) {
    tmp = b % 10;
    s[++cnt] = tmp;
    b /= 10;
  }
  int p = 1;
  for (int i = cnt; i >= 1; i--) {
    sum += s[i] * p;
    p *= 10;
  }
  return sum;
}
using namespace std;
int main() {
  int a[105], n;
  for (int i = 2; i <= 1000000; i++)
    if (!prime[i])
      for (int j = i + i; j <= 1000000; j += i) prime[j] = true;
  while (cin >> n) {
    int num = 10, cnt(0);
    while (cnt < n) {
      num++;
      if (!prime[num] && !prime[change(num)] && num != change(num)) cnt++;
    }
    cout << num << endl;
  }
}

### Prompt

Your task is to create 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>
int prime[1000005];
int change(int b) {
  int s[50], tmp(0), cnt(0), sum(0);
  while (b) {
    tmp = b % 10;
    s[++cnt] = tmp;
    b /= 10;
  }
  int p = 1;
  for (int i = cnt; i >= 1; i--) {
    sum += s[i] * p;
    p *= 10;
  }
  return sum;
}
using namespace std;
int main() {
  int a[105], n;
  for (int i = 2; i <= 1000000; i++)
    if (!prime[i])
      for (int j = i + i; j <= 1000000; j += i) prime[j] = true;
  while (cin >> n) {
    int num = 10, cnt(0);
    while (cnt < n) {
      num++;
      if (!prime[num] && !prime[change(num)] && num != change(num)) cnt++;
    }
    cout << num << endl;
  }
}

```