#include <bits/stdc++.h>
using namespace std;
long long int vis[1000005];
void prime() {
  for (int i = 1; i <= 1000000; i++) vis[i] = true;
  vis[1] = false;
  for (int i = 2; i * i <= 1000000; i++) {
    if (vis[i]) {
      for (int j = i * 2; j <= 1000000; j += i) vis[j] = false;
    }
  }
}
long long int reverse(long long int n) {
  long long int ans = 0;
  while (n) {
    ans = ans * 10 + n % 10;
    n /= 10;
  }
  return ans;
}
int main() {
  vector<long long int> v;
  prime();
  for (int i = 1; i <= 1000000; i++) {
    if (vis[i] and vis[reverse(i)] and i != reverse(i)) v.push_back(i);
  }
  long long int n;
  cin >> n;
  cout << v[n - 1] << endl;
}

### 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;
long long int vis[1000005];
void prime() {
  for (int i = 1; i <= 1000000; i++) vis[i] = true;
  vis[1] = false;
  for (int i = 2; i * i <= 1000000; i++) {
    if (vis[i]) {
      for (int j = i * 2; j <= 1000000; j += i) vis[j] = false;
    }
  }
}
long long int reverse(long long int n) {
  long long int ans = 0;
  while (n) {
    ans = ans * 10 + n % 10;
    n /= 10;
  }
  return ans;
}
int main() {
  vector<long long int> v;
  prime();
  for (int i = 1; i <= 1000000; i++) {
    if (vis[i] and vis[reverse(i)] and i != reverse(i)) v.push_back(i);
  }
  long long int n;
  cin >> n;
  cout << v[n - 1] << endl;
}

```