#include <bits/stdc++.h>
using namespace std;
vector<bool> prime;
bool OK(int n) {
  if (!prime[n]) return false;
  int i, N = n, s = 0, del = 1;
  vector<int> v;
  while (n) {
    v.push_back(n % 10);
    n /= 10;
  }
  for (i = v.size() - 1; i >= 0; i--) {
    s += v[i] * del;
    del *= 10;
  }
  if (!prime[s] || s == N) return false;
  return true;
}
int main() {
  int i, j, n, kol = 0;
  cin >> n;
  prime.assign(1000001, true);
  for (i = 2; i * i <= 1000000; i++)
    if (prime[i])
      for (j = i * i; j <= 1000000; j += i) prime[j] = false;
  i = 11;
  while (kol < n) {
    if (OK(i)) kol++;
    i++;
  }
  cout << i - 1 << endl;
  return 0;
}

### Prompt

Please formulate 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;
vector<bool> prime;
bool OK(int n) {
  if (!prime[n]) return false;
  int i, N = n, s = 0, del = 1;
  vector<int> v;
  while (n) {
    v.push_back(n % 10);
    n /= 10;
  }
  for (i = v.size() - 1; i >= 0; i--) {
    s += v[i] * del;
    del *= 10;
  }
  if (!prime[s] || s == N) return false;
  return true;
}
int main() {
  int i, j, n, kol = 0;
  cin >> n;
  prime.assign(1000001, true);
  for (i = 2; i * i <= 1000000; i++)
    if (prime[i])
      for (j = i * i; j <= 1000000; j += i) prime[j] = false;
  i = 11;
  while (kol < n) {
    if (OK(i)) kol++;
    i++;
  }
  cout << i - 1 << endl;
  return 0;
}

```