#include <bits/stdc++.h>
int n;
bool check(int v) {
  for (int i = 2; i <= (int)sqrt(v); ++i)
    if (v % i == 0) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  int cnt = 0;
  int zz = 13;
  while (cnt != n) {
    int tot = 0;
    int gzz = zz;
    while (gzz != 0) {
      tot = tot * 10 + gzz % 10;
      gzz /= 10;
    }
    if (tot != zz && check(tot) && check(zz)) cnt++;
    if (cnt == n) break;
    zz++;
  }
  printf("%d\n", zz);
}

### Prompt

Your challenge is to write 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>
int n;
bool check(int v) {
  for (int i = 2; i <= (int)sqrt(v); ++i)
    if (v % i == 0) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  int cnt = 0;
  int zz = 13;
  while (cnt != n) {
    int tot = 0;
    int gzz = zz;
    while (gzz != 0) {
      tot = tot * 10 + gzz % 10;
      gzz /= 10;
    }
    if (tot != zz && check(tot) && check(zz)) cnt++;
    if (cnt == n) break;
    zz++;
  }
  printf("%d\n", zz);
}

```