#include <bits/stdc++.h>
using namespace std;
int rev(int n) {
  int res = 0;
  while (n) {
    res *= 10;
    res += n % 10;
    n /= 10;
  }
  return res;
}
bool prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  vector<int> tt;
  for (int i = 2;; ++i) {
    if (!prime(i)) continue;
    int t = rev(i);
    if (t == i) continue;
    if (!prime(t)) continue;
    tt.push_back(i);
    if (tt.size() == n) break;
  }
  cout << tt.back();
}

### Prompt

Your challenge is to write 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;
int rev(int n) {
  int res = 0;
  while (n) {
    res *= 10;
    res += n % 10;
    n /= 10;
  }
  return res;
}
bool prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  vector<int> tt;
  for (int i = 2;; ++i) {
    if (!prime(i)) continue;
    int t = rev(i);
    if (t == i) continue;
    if (!prime(t)) continue;
    tt.push_back(i);
    if (tt.size() == n) break;
  }
  cout << tt.back();
}

```