#include <bits/stdc++.h>
using namespace std;
vector<long> ans;
long pr[2000000];
long rev(long x) {
  long res = 0;
  while (x) {
    res = res * 10 + x % 10;
    x /= 10;
  }
  return res;
}
long n;
int main() {
  ios_base::sync_with_stdio(0);
  pr[1] = 1;
  for (int i = 2; i <= 1000000; i++)
    if (pr[i] == 0)
      for (int j = 2 * i; j <= 1000000; j += i) pr[j] = 1;
  for (int j = 1; j <= 1000000; j++)
    if (pr[j] == 0 && pr[rev(j)] == 0 && rev(j) != j) ans.push_back(j);
  cin >> n;
  cout << ans[n - 1] << endl;
  cin.get();
  cin.get();
  return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

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<long> ans;
long pr[2000000];
long rev(long x) {
  long res = 0;
  while (x) {
    res = res * 10 + x % 10;
    x /= 10;
  }
  return res;
}
long n;
int main() {
  ios_base::sync_with_stdio(0);
  pr[1] = 1;
  for (int i = 2; i <= 1000000; i++)
    if (pr[i] == 0)
      for (int j = 2 * i; j <= 1000000; j += i) pr[j] = 1;
  for (int j = 1; j <= 1000000; j++)
    if (pr[j] == 0 && pr[rev(j)] == 0 && rev(j) != j) ans.push_back(j);
  cin >> n;
  cout << ans[n - 1] << endl;
  cin.get();
  cin.get();
  return 0;
}

```