#include <bits/stdc++.h>
using namespace std;
int n, sum = 0, m, s;
int ss(int x) {
  for (int i = 2; i <= sqrt(x); i++)
    if (x % i == 0) return 1;
  return 0;
}
int main() {
  int i = 1;
  cin >> n;
  while (sum < n) {
    i++;
    m = i, s = 0;
    while (m > 0) {
      s = s * 10 + m % 10;
      m /= 10;
    }
    if (ss(i) == 0 && ss(s) == 0 && i != s) sum++;
  }
  cout << i;
  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;
int n, sum = 0, m, s;
int ss(int x) {
  for (int i = 2; i <= sqrt(x); i++)
    if (x % i == 0) return 1;
  return 0;
}
int main() {
  int i = 1;
  cin >> n;
  while (sum < n) {
    i++;
    m = i, s = 0;
    while (m > 0) {
      s = s * 10 + m % 10;
      m /= 10;
    }
    if (ss(i) == 0 && ss(s) == 0 && i != s) sum++;
  }
  cout << i;
  return 0;
}

```