#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
int notpr[N + 1];
int rev(int a) {
  int b = 0;
  while (a > 0) {
    b += a % 10;
    b *= 10;
    a /= 10;
  }
  return b / 10;
}
int main() {
  vector<int> primes;
  notpr[1] = true;
  notpr[0] = true;
  for (int i = 2; i <= N; ++i)
    if (notpr[i] == 0) {
      primes.push_back(i);
      for (int j = 2; j * i <= N; ++j) {
        notpr[i * j] = true;
      }
    }
  int n, g = 0;
  cin >> n;
  for (int i = 0; i < primes.size(); ++i)
    if (notpr[rev(primes[i])] == false && primes[i] != rev(primes[i])) {
      g++;
      if (g == n) {
        cout << (primes[i]) << endl;
        return 0;
      }
    }
}

### Prompt

Your task is to create 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;
const int N = 1000000;
int notpr[N + 1];
int rev(int a) {
  int b = 0;
  while (a > 0) {
    b += a % 10;
    b *= 10;
    a /= 10;
  }
  return b / 10;
}
int main() {
  vector<int> primes;
  notpr[1] = true;
  notpr[0] = true;
  for (int i = 2; i <= N; ++i)
    if (notpr[i] == 0) {
      primes.push_back(i);
      for (int j = 2; j * i <= N; ++j) {
        notpr[i * j] = true;
      }
    }
  int n, g = 0;
  cin >> n;
  for (int i = 0; i < primes.size(); ++i)
    if (notpr[rev(primes[i])] == false && primes[i] != rev(primes[i])) {
      g++;
      if (g == n) {
        cout << (primes[i]) << endl;
        return 0;
      }
    }
}

```