#include <bits/stdc++.h>
using namespace std;
bool check(int u) {
  for (int i = 2; i * i <= u; i++)
    if (u % i == 0) return 0;
  stringstream num;
  num << u;
  string str, str2;
  num >> str;
  str2 = str;
  reverse(str.begin(), str.end());
  if (str2 == str) return 0;
  num.clear();
  num << str;
  int t;
  num >> t;
  for (int i = 2; i * i <= t; i++)
    if (t % i == 0) return 0;
  return 1;
}
int main() {
  int n;
  cin >> n;
  for (int i = 2;; i++) {
    if (check(i)) n--;
    if (!n) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

### Prompt

In CPP, your task is to solve 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 check(int u) {
  for (int i = 2; i * i <= u; i++)
    if (u % i == 0) return 0;
  stringstream num;
  num << u;
  string str, str2;
  num >> str;
  str2 = str;
  reverse(str.begin(), str.end());
  if (str2 == str) return 0;
  num.clear();
  num << str;
  int t;
  num >> t;
  for (int i = 2; i * i <= t; i++)
    if (t % i == 0) return 0;
  return 1;
}
int main() {
  int n;
  cin >> n;
  for (int i = 2;; i++) {
    if (check(i)) n--;
    if (!n) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

```