#include <bits/stdc++.h>
using namespace std;
long long n, a = 10, b, am, ans;
int main() {
  cin >> n;
  while (am != n) {
    a++;
    bool flag = true;
    for (int i = 2; i * i <= a; i++)
      if (a % i == 0) {
        flag = false;
        break;
      }
    if (flag) {
      long long aa = a;
      b = 0;
      while (aa > 0) b = b * 10 + aa % 10, aa /= 10;
      for (int i = 2; i * i <= b; i++)
        if (b % i == 0) {
          flag = false;
          break;
        }
      if (flag && a != b) am++, ans = a;
    }
  }
  cout << ans;
  return 0;
}

### Prompt

Please create a solution in CPP 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;
long long n, a = 10, b, am, ans;
int main() {
  cin >> n;
  while (am != n) {
    a++;
    bool flag = true;
    for (int i = 2; i * i <= a; i++)
      if (a % i == 0) {
        flag = false;
        break;
      }
    if (flag) {
      long long aa = a;
      b = 0;
      while (aa > 0) b = b * 10 + aa % 10, aa /= 10;
      for (int i = 2; i * i <= b; i++)
        if (b % i == 0) {
          flag = false;
          break;
        }
      if (flag && a != b) am++, ans = a;
    }
  }
  cout << ans;
  return 0;
}

```