#include <bits/stdc++.h>
using namespace std;
char mmap[200];
bool is_prime(int n) {
  int i;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  int i;
  for (i = 0; i < 200; i++) mmap[i] = '_';
  mmap[' '] = ' ';
  mmap['j'] = 't';
  mmap['x'] = 'h';
  mmap['u'] = 'e';
  mmap['y'] = 'i';
  mmap['d'] = 'n';
  mmap['w'] = 'g';
  mmap['h'] = 'r';
  mmap['f'] = 'p';
  mmap['k'] = 'u';
  mmap['e'] = 'o';
  mmap['v'] = 'f';
  mmap['s'] = 'c';
  mmap['i'] = 's';
  mmap['q'] = 'a';
  mmap['b'] = 'l';
  mmap['.'] = '.';
  mmap['c'] = 'm';
  mmap['r'] = 'b';
  mmap['m'] = 'w';
  mmap['t'] = 'd';
  mmap['l'] = 'v';
  char c[] =
      "qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. "
      "oekh jqia yi je vydt jxu djx ucyhf.";
  int n;
  cin >> n;
  int rev;
  int k = 0;
  for (i = 2;; i++) {
    rev = 0;
    int ii = i;
    if (!is_prime(i)) continue;
    while (ii > 0) {
      rev *= 10;
      rev += ii % 10;
      ii /= 10;
    }
    if (rev == i) continue;
    if (!is_prime(rev)) continue;
    k++;
    if (k >= n) {
      cout << i << endl;
      return 0;
    }
  }
  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;
char mmap[200];
bool is_prime(int n) {
  int i;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  int i;
  for (i = 0; i < 200; i++) mmap[i] = '_';
  mmap[' '] = ' ';
  mmap['j'] = 't';
  mmap['x'] = 'h';
  mmap['u'] = 'e';
  mmap['y'] = 'i';
  mmap['d'] = 'n';
  mmap['w'] = 'g';
  mmap['h'] = 'r';
  mmap['f'] = 'p';
  mmap['k'] = 'u';
  mmap['e'] = 'o';
  mmap['v'] = 'f';
  mmap['s'] = 'c';
  mmap['i'] = 's';
  mmap['q'] = 'a';
  mmap['b'] = 'l';
  mmap['.'] = '.';
  mmap['c'] = 'm';
  mmap['r'] = 'b';
  mmap['m'] = 'w';
  mmap['t'] = 'd';
  mmap['l'] = 'v';
  char c[] =
      "qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. "
      "oekh jqia yi je vydt jxu djx ucyhf.";
  int n;
  cin >> n;
  int rev;
  int k = 0;
  for (i = 2;; i++) {
    rev = 0;
    int ii = i;
    if (!is_prime(i)) continue;
    while (ii > 0) {
      rev *= 10;
      rev += ii % 10;
      ii /= 10;
    }
    if (rev == i) continue;
    if (!is_prime(rev)) continue;
    k++;
    if (k >= n) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

```