#include <bits/stdc++.h>
using namespace std;
long long int isprim[1000007];
bool plin(int x) {
  string s, t;
  stringstream k;
  k << x;
  s = k.str();
  t = s;
  reverse(s.begin(), s.end());
  if (s != t) return true;
  return false;
}
int conv(int x) {
  string s;
  stringstream k;
  k << x;
  s = k.str();
  reverse(s.begin(), s.end());
  long long int y;
  stringstream n(s);
  n >> y;
  return y;
}
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int x;
  cin >> x;
  vector<long long int> num, prime;
  long long int n = 1000000000007, j;
  isprim[0] = isprim[1] = 1;
  for (long long int i = 2; i * i < n; i++) {
    if (!isprim[i]) num.push_back(i);
    for (long long int j = i * i; j < sqrt(n); j += i) isprim[j] = 1;
  }
  for (int i = 0; i < num.size(); i++) {
    if (!isprim[conv(num[i])] && !isprim[num[i]] && plin(num[i]))
      prime.push_back(num[i]);
    if (prime.size() == x) break;
  }
  cout << prime[x - 1] << endl;
  return 0;
}

### Prompt

Create a solution in CPP for 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 int isprim[1000007];
bool plin(int x) {
  string s, t;
  stringstream k;
  k << x;
  s = k.str();
  t = s;
  reverse(s.begin(), s.end());
  if (s != t) return true;
  return false;
}
int conv(int x) {
  string s;
  stringstream k;
  k << x;
  s = k.str();
  reverse(s.begin(), s.end());
  long long int y;
  stringstream n(s);
  n >> y;
  return y;
}
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int x;
  cin >> x;
  vector<long long int> num, prime;
  long long int n = 1000000000007, j;
  isprim[0] = isprim[1] = 1;
  for (long long int i = 2; i * i < n; i++) {
    if (!isprim[i]) num.push_back(i);
    for (long long int j = i * i; j < sqrt(n); j += i) isprim[j] = 1;
  }
  for (int i = 0; i < num.size(); i++) {
    if (!isprim[conv(num[i])] && !isprim[num[i]] && plin(num[i]))
      prime.push_back(num[i]);
    if (prime.size() == x) break;
  }
  cout << prime[x - 1] << endl;
  return 0;
}

```