#include <bits/stdc++.h>
using namespace std;
double EPS = 1e-9;
int INF = 2000000000;
long long INFF = 8000000000000000000LL;
double PI = acos(-1);
inline string IntToString(int a) {
  char x[100];
  sprintf(x, "%d", a);
  string s = x;
  return s;
}
inline int StringToInt(string a) {
  char x[100];
  int res;
  strcpy(x, a.c_str());
  sscanf(x, "%d", &res);
  return res;
}
inline string GetString(void) {
  char x[1000005];
  scanf("%s", x);
  string s = x;
  return s;
}
inline bool angka(char a) { return (a >= '0' && a <= '9'); }
inline bool kecil(char a) { return (a >= 'a' && a <= 'z'); }
inline bool besar(char a) { return (a >= 'A' && a <= 'Z'); }
inline string uppercase(string s) {
  int n = (int)s.size();
  for (int(i) = (0); (i) < (n); (i)++)
    if (kecil(s[i])) s[i] = s[i] - 'a' + 'A';
  return s;
}
inline string lowercase(string s) {
  int n = (int)s.size();
  for (int(i) = (0); (i) < (n); (i)++)
    if (besar(s[i])) s[i] = s[i] - 'A' + 'a';
  return s;
}
bool pr[1000000 + 5];
int prima[1000000 + 5];
void GeneratePrime(int a) {
  memset(pr, 1, sizeof(pr));
  pr[0] = pr[1] = 0;
  int ix = 0;
  for (int(i) = (2); (i) <= (a); (i)++)
    if (pr[i]) {
      prima[++ix] = i;
      int b = i * 2;
      while (b <= a) {
        pr[b] = 0;
        b += i;
      }
    }
}
string s;
int k, n = 0;
int main() {
  GeneratePrime(1000000);
  cin >> k;
  for (int(i) = (1); (i) <= (INF); (i)++) {
    int cek = i;
    s = IntToString(cek);
    reverse(s.begin(), s.end());
    cek = StringToInt(s);
    if (cek != i && pr[cek] && pr[i]) n++;
    if (n == k) {
      printf("%d\n", i);
      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;
double EPS = 1e-9;
int INF = 2000000000;
long long INFF = 8000000000000000000LL;
double PI = acos(-1);
inline string IntToString(int a) {
  char x[100];
  sprintf(x, "%d", a);
  string s = x;
  return s;
}
inline int StringToInt(string a) {
  char x[100];
  int res;
  strcpy(x, a.c_str());
  sscanf(x, "%d", &res);
  return res;
}
inline string GetString(void) {
  char x[1000005];
  scanf("%s", x);
  string s = x;
  return s;
}
inline bool angka(char a) { return (a >= '0' && a <= '9'); }
inline bool kecil(char a) { return (a >= 'a' && a <= 'z'); }
inline bool besar(char a) { return (a >= 'A' && a <= 'Z'); }
inline string uppercase(string s) {
  int n = (int)s.size();
  for (int(i) = (0); (i) < (n); (i)++)
    if (kecil(s[i])) s[i] = s[i] - 'a' + 'A';
  return s;
}
inline string lowercase(string s) {
  int n = (int)s.size();
  for (int(i) = (0); (i) < (n); (i)++)
    if (besar(s[i])) s[i] = s[i] - 'A' + 'a';
  return s;
}
bool pr[1000000 + 5];
int prima[1000000 + 5];
void GeneratePrime(int a) {
  memset(pr, 1, sizeof(pr));
  pr[0] = pr[1] = 0;
  int ix = 0;
  for (int(i) = (2); (i) <= (a); (i)++)
    if (pr[i]) {
      prima[++ix] = i;
      int b = i * 2;
      while (b <= a) {
        pr[b] = 0;
        b += i;
      }
    }
}
string s;
int k, n = 0;
int main() {
  GeneratePrime(1000000);
  cin >> k;
  for (int(i) = (1); (i) <= (INF); (i)++) {
    int cek = i;
    s = IntToString(cek);
    reverse(s.begin(), s.end());
    cek = StringToInt(s);
    if (cek != i && pr[cek] && pr[i]) n++;
    if (n == k) {
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}

```