#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
const int M = 1e4;
const long double EPS = 1e-14;
const long long INF = 1e9;
const int MOD = 1e9 + 7;
long long rev(long long a) {
  long long k = 0;
  while (a > 0) {
    k = k * 10 + a % 10;
    a /= 10;
  }
  return k;
}
bool check(long long a) {
  for (int i = 2; i * i <= a; i++)
    if (a % i == 0) return false;
  return true;
}
vector<long long> a;
void solve() {
  long long i = 2;
  while (a.size() < 11185) {
    if (check(i) && check(rev(i)) && rev(i) != i) a.push_back(i);
    i++;
  }
  int n;
  cin >> n;
  cout << a[n - 1] << endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  solve();
}

### 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;
const int N = 1000;
const int M = 1e4;
const long double EPS = 1e-14;
const long long INF = 1e9;
const int MOD = 1e9 + 7;
long long rev(long long a) {
  long long k = 0;
  while (a > 0) {
    k = k * 10 + a % 10;
    a /= 10;
  }
  return k;
}
bool check(long long a) {
  for (int i = 2; i * i <= a; i++)
    if (a % i == 0) return false;
  return true;
}
vector<long long> a;
void solve() {
  long long i = 2;
  while (a.size() < 11185) {
    if (check(i) && check(rev(i)) && rev(i) != i) a.push_back(i);
    i++;
  }
  int n;
  cin >> n;
  cout << a[n - 1] << endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  solve();
}

```