#include <bits/stdc++.h>
using namespace std;
int primes[1000000];
void gen_primes() {
  for (int i = 0; i < 1000000; ++i) primes[i] = 1;
  primes[0] = primes[1] = 0;
  for (int i = 2; i < (int)sqrt(1000000); ++i)
    if (primes[i])
      for (int j = i * i; j < 1000000; j += i) primes[j] = 0;
}
bool is_eotsorp(int n) {
  int k = n;
  string _n = to_string(n);
  reverse(_n.begin(), _n.end());
  n = stoi(_n);
  if (k != n && primes[n])
    return true;
  else
    return false;
}
int main() {
  gen_primes();
  vector<int> g;
  int n;
  cin >> n;
  for (int i = 2; i < 1000000; ++i)
    if (primes[i] && is_eotsorp(i)) g.push_back(i);
  cout << g[--n];
  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 primes[1000000];
void gen_primes() {
  for (int i = 0; i < 1000000; ++i) primes[i] = 1;
  primes[0] = primes[1] = 0;
  for (int i = 2; i < (int)sqrt(1000000); ++i)
    if (primes[i])
      for (int j = i * i; j < 1000000; j += i) primes[j] = 0;
}
bool is_eotsorp(int n) {
  int k = n;
  string _n = to_string(n);
  reverse(_n.begin(), _n.end());
  n = stoi(_n);
  if (k != n && primes[n])
    return true;
  else
    return false;
}
int main() {
  gen_primes();
  vector<int> g;
  int n;
  cin >> n;
  for (int i = 2; i < 1000000; ++i)
    if (primes[i] && is_eotsorp(i)) g.push_back(i);
  cout << g[--n];
  return 0;
}

```