#include <bits/stdc++.h>
using namespace std;
const long long INF = 9999999999999999;
const double PI = acos(-1);
bool prime(long long n) {
  for (long long i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  long long a;
  cin >> a;
  long long sum = 0, c;
  for (long long i = 13; i < 1000000; i++) {
    if (!prime(i)) continue;
    string ss = to_string(i);
    string s = to_string(i);
    long long n = s.size();
    for (long long i = n - 1, j = 0; i >= 0; i--, j++) {
      s[j] = ss[i];
    }
    c = atoi(s.c_str());
    if (c == i) continue;
    if (prime(c)) sum++;
    if (sum == a) {
      cout << i;
      break;
    }
  }
  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 long long INF = 9999999999999999;
const double PI = acos(-1);
bool prime(long long n) {
  for (long long i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  long long a;
  cin >> a;
  long long sum = 0, c;
  for (long long i = 13; i < 1000000; i++) {
    if (!prime(i)) continue;
    string ss = to_string(i);
    string s = to_string(i);
    long long n = s.size();
    for (long long i = n - 1, j = 0; i >= 0; i--, j++) {
      s[j] = ss[i];
    }
    c = atoi(s.c_str());
    if (c == i) continue;
    if (prime(c)) sum++;
    if (sum == a) {
      cout << i;
      break;
    }
  }
  return 0;
}

```