#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000 * 1000 + 100;
int p[maxN];
vector<int> pr;
int main() {
  ios::sync_with_stdio(false);
  int d;
  cin >> d;
  p[1] = p[0] = 1;
  for (int i = 2; i < maxN; i++)
    if (!p[i]) {
      for (int j = i + i; j < maxN; j += i) p[j] = 1;
      pr.push_back(i);
    }
  for (int i = 0; i < pr.size() && d; i++) {
    int x = pr[i];
    int y = 0;
    while (x) y = y * 10 + x % 10, x /= 10;
    if (!p[y] && y != pr[i]) {
      d--;
      if (d == 0) {
        cout << pr[i] << endl;
        cin >> d;
        return 0;
      }
    }
  }
}

### Prompt

In CPP, your task is to solve 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 maxN = 1000 * 1000 + 100;
int p[maxN];
vector<int> pr;
int main() {
  ios::sync_with_stdio(false);
  int d;
  cin >> d;
  p[1] = p[0] = 1;
  for (int i = 2; i < maxN; i++)
    if (!p[i]) {
      for (int j = i + i; j < maxN; j += i) p[j] = 1;
      pr.push_back(i);
    }
  for (int i = 0; i < pr.size() && d; i++) {
    int x = pr[i];
    int y = 0;
    while (x) y = y * 10 + x % 10, x /= 10;
    if (!p[y] && y != pr[i]) {
      d--;
      if (d == 0) {
        cout << pr[i] << endl;
        cin >> d;
        return 0;
      }
    }
  }
}

```