#include <bits/stdc++.h>
using namespace std;
bool prime(int x) {
  if (x % 2 == 0)
    return false;
  else {
    for (int i = 3; i <= (int)sqrt(x); i += 2)
      if (x % i == 0) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  int cnt = 0, base = 13;
  while (cnt != n) {
    int sum = 0, z = base;
    while (z != 0) {
      sum = sum * 10 + z % 10;
      z /= 10;
    }
    if (sum != base && prime(sum) && prime(base)) cnt++;
    if (cnt == n) break;
    base++;
  }
  cout << base << endl;
}

### 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 prime(int x) {
  if (x % 2 == 0)
    return false;
  else {
    for (int i = 3; i <= (int)sqrt(x); i += 2)
      if (x % i == 0) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  int cnt = 0, base = 13;
  while (cnt != n) {
    int sum = 0, z = base;
    while (z != 0) {
      sum = sum * 10 + z % 10;
      z /= 10;
    }
    if (sum != base && prime(sum) && prime(base)) cnt++;
    if (cnt == n) break;
    base++;
  }
  cout << base << endl;
}

```