#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 1e7;
  vector<char> prime(n + 1, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i <= n; ++i)
    if (prime[i])
      if (i * 1ll * i <= n)
        for (int j = i * i; j <= n; j += i) prime[j] = false;
  int ar[11186] = {};
  int c = 1, nu = 10;
  while (c <= 11184) {
    if (prime[nu]) {
      string s = to_string(nu);
      reverse(s.begin(), s.end());
      int rev = atoi(s.c_str());
      if (prime[rev] && rev != nu) ar[c] = nu, c++;
    }
    nu++;
  }
  int v;
  cin >> v;
  cout << ar[v];
}

### 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 main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 1e7;
  vector<char> prime(n + 1, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i <= n; ++i)
    if (prime[i])
      if (i * 1ll * i <= n)
        for (int j = i * i; j <= n; j += i) prime[j] = false;
  int ar[11186] = {};
  int c = 1, nu = 10;
  while (c <= 11184) {
    if (prime[nu]) {
      string s = to_string(nu);
      reverse(s.begin(), s.end());
      int rev = atoi(s.c_str());
      if (prime[rev] && rev != nu) ar[c] = nu, c++;
    }
    nu++;
  }
  int v;
  cin >> v;
  cout << ar[v];
}

```