#include <bits/stdc++.h>
using namespace std;
int reverse(int a) {
  int b = 0;
  while (a > 0) {
    b *= 10;
    b += a % 10;
    a /= 10;
  }
  return b;
}
int sieve[1000123] = {1};
void doPrime() {
  for (int i = 0; i < 1000123; i++) sieve[i] = 1;
  for (int i = 2; i < 1000123; i++) {
    for (int j = 2; i * j < 1000123; j++) sieve[i * j] = 0;
  }
  return;
}
int main() {
  int a;
  cin >> a;
  int counter = 0, current = 0;
  doPrime();
  for (int i = 1; counter < a && i < 1000123; i++) {
    if (sieve[i] == 1) {
      int r = reverse(i);
      if (r != i && sieve[r] == 1) {
        counter++;
        current = i;
      }
    }
  }
  cout << current;
  return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

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;
int reverse(int a) {
  int b = 0;
  while (a > 0) {
    b *= 10;
    b += a % 10;
    a /= 10;
  }
  return b;
}
int sieve[1000123] = {1};
void doPrime() {
  for (int i = 0; i < 1000123; i++) sieve[i] = 1;
  for (int i = 2; i < 1000123; i++) {
    for (int j = 2; i * j < 1000123; j++) sieve[i * j] = 0;
  }
  return;
}
int main() {
  int a;
  cin >> a;
  int counter = 0, current = 0;
  doPrime();
  for (int i = 1; counter < a && i < 1000123; i++) {
    if (sieve[i] == 1) {
      int r = reverse(i);
      if (r != i && sieve[r] == 1) {
        counter++;
        current = i;
      }
    }
  }
  cout << current;
  return 0;
}

```