#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
void solve();
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  while (t--) solve();
}
void solve() {
  vector<long long> v;
  for (long long i = 2; i < 1000000; i++) {
    string s = to_string(i);
    reverse(s.begin(), s.end());
    long long lol = stoi(s);
    if (isPrime(i) && isPrime(lol) && i != lol) v.push_back(i);
  }
  long long n;
  cin >> n;
  cout << v[n - 1] << endl;
}

### Prompt

Your task is to create 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;
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
void solve();
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  while (t--) solve();
}
void solve() {
  vector<long long> v;
  for (long long i = 2; i < 1000000; i++) {
    string s = to_string(i);
    reverse(s.begin(), s.end());
    long long lol = stoi(s);
    if (isPrime(i) && isPrime(lol) && i != lol) v.push_back(i);
  }
  long long n;
  cin >> n;
  cout << v[n - 1] << endl;
}

```