#include <bits/stdc++.h>
using namespace std;
long long labs(long long a) { return a < 0 ? (-a) : a; }
const int MAXN = 1000001;
void GetPrimes(int n, vector<bool>& prime) {
  n++;
  prime.assign(n, true);
  if (n >= 0) prime[0] = false;
  if (n >= 1) prime[1] = false;
  for (int(i) = 0; (i) < (n); (i)++) {
    if (prime[i]) {
      for (int j = 2; j * i < n; j++) {
        prime[i * j] = false;
      }
    }
  }
}
vector<bool> primes;
int Mirror(int a) {
  int b = 0;
  while (a) {
    b *= 10;
    b += a % 10;
    a /= 10;
  }
  return b;
}
int main() {
  int n;
  cin >> n;
  GetPrimes(MAXN, primes);
  int num = 0;
  for (int(i) = 0; (i) < (MAXN); (i)++) {
    if (primes[i] && primes[Mirror(i)] && i != Mirror(i)) {
      num++;
    }
    if (num == n) {
      cout << i << endl;
      return 0;
    }
  }
  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;
long long labs(long long a) { return a < 0 ? (-a) : a; }
const int MAXN = 1000001;
void GetPrimes(int n, vector<bool>& prime) {
  n++;
  prime.assign(n, true);
  if (n >= 0) prime[0] = false;
  if (n >= 1) prime[1] = false;
  for (int(i) = 0; (i) < (n); (i)++) {
    if (prime[i]) {
      for (int j = 2; j * i < n; j++) {
        prime[i * j] = false;
      }
    }
  }
}
vector<bool> primes;
int Mirror(int a) {
  int b = 0;
  while (a) {
    b *= 10;
    b += a % 10;
    a /= 10;
  }
  return b;
}
int main() {
  int n;
  cin >> n;
  GetPrimes(MAXN, primes);
  int num = 0;
  for (int(i) = 0; (i) < (MAXN); (i)++) {
    if (primes[i] && primes[Mirror(i)] && i != Mirror(i)) {
      num++;
    }
    if (num == n) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

```