#include <bits/stdc++.h>
using namespace std;
long long reverse(long long x) {
  long long res = 0;
  while (x > 0) {
    res += x % 10;
    res *= 10;
    x /= 10;
  }
  res /= 10;
  return res;
}
bool check(long long x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int main() {
  long long n = 2, num = 0, m;
  cin >> m;
  while (num < m) {
    if ((n != reverse(n)) && (check(reverse(n))) && (check(n))) {
      num++;
    }
    n++;
  }
  cout << n - 1;
  return 0;
}

### Prompt

Please provide a cpp coded solution 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>
using namespace std;
long long reverse(long long x) {
  long long res = 0;
  while (x > 0) {
    res += x % 10;
    res *= 10;
    x /= 10;
  }
  res /= 10;
  return res;
}
bool check(long long x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int main() {
  long long n = 2, num = 0, m;
  cin >> m;
  while (num < m) {
    if ((n != reverse(n)) && (check(reverse(n))) && (check(n))) {
      num++;
    }
    n++;
  }
  cout << n - 1;
  return 0;
}

```