#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
long long int mod;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  x = x % mod;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
long long int mulmod(long long int a, long long int b, long long int c) {
  long long int x = 0, y = a % c;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x + y) % c;
    }
    y = (y * 2LL) % c;
    b /= 2;
  }
  return x % c;
}
long long int binPower(long long int a, long long int n, long long int mod) {
  long long int res = 1;
  while (n) {
    if (n & 1) res = mulmod(res, a, mod);
    n >>= 1;
    a = mulmod(a, a, mod);
  }
  return res % mod;
}
long long int probablyPrime(long long int n) {
  if (n <= 4) return n == 2 || n == 3;
  long long int a, i;
  for (i = 0; i < 3; i++) {
    a = 2 + rand() % (n - 3);
    if (binPower(a, n - 1, n) != 1) return 0;
  }
  return 1;
}
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t = 1, n, i, j, k, len, x, y, z, c, f, flag, p, q, mx, mn, l, r,
                sum, ans, tmp, it, pos, avg, m, cnt;
  string s;
  char ch;
  vector<long long int> v;
  vector<pair<long long int, long long int>> vec;
  unordered_map<long long int, long long int> mappu;
  pair<long long int, long long int> pr;
  {
    f = 0;
    sum = 0;
    flag = 0;
    ans = 0;
    cnt = 0;
    v.clear();
    mappu.clear();
    vec.clear();
    cin >> n;
    i = 13;
    while (v.size() < n) {
      p = i;
      q = 0;
      cnt = 0;
      mod = p;
      if (isPrime(p))
        cnt++;
      else {
        i++;
        continue;
      }
      tmp = i;
      while (tmp > 0) {
        q *= 10;
        q += tmp % 10;
        tmp /= 10;
      }
      if (p == q) {
        i++;
        continue;
      }
      mod = q;
      if (isPrime(q)) cnt++;
      if (cnt == 2) v.push_back(i);
      i++;
    }
    cout << v.back();
  }
  return 0;
}

### Prompt

Develop a solution in CPP to the problem described below:

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>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
long long int mod;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  x = x % mod;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
long long int mulmod(long long int a, long long int b, long long int c) {
  long long int x = 0, y = a % c;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x + y) % c;
    }
    y = (y * 2LL) % c;
    b /= 2;
  }
  return x % c;
}
long long int binPower(long long int a, long long int n, long long int mod) {
  long long int res = 1;
  while (n) {
    if (n & 1) res = mulmod(res, a, mod);
    n >>= 1;
    a = mulmod(a, a, mod);
  }
  return res % mod;
}
long long int probablyPrime(long long int n) {
  if (n <= 4) return n == 2 || n == 3;
  long long int a, i;
  for (i = 0; i < 3; i++) {
    a = 2 + rand() % (n - 3);
    if (binPower(a, n - 1, n) != 1) return 0;
  }
  return 1;
}
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t = 1, n, i, j, k, len, x, y, z, c, f, flag, p, q, mx, mn, l, r,
                sum, ans, tmp, it, pos, avg, m, cnt;
  string s;
  char ch;
  vector<long long int> v;
  vector<pair<long long int, long long int>> vec;
  unordered_map<long long int, long long int> mappu;
  pair<long long int, long long int> pr;
  {
    f = 0;
    sum = 0;
    flag = 0;
    ans = 0;
    cnt = 0;
    v.clear();
    mappu.clear();
    vec.clear();
    cin >> n;
    i = 13;
    while (v.size() < n) {
      p = i;
      q = 0;
      cnt = 0;
      mod = p;
      if (isPrime(p))
        cnt++;
      else {
        i++;
        continue;
      }
      tmp = i;
      while (tmp > 0) {
        q *= 10;
        q += tmp % 10;
        tmp /= 10;
      }
      if (p == q) {
        i++;
        continue;
      }
      mod = q;
      if (isPrime(q)) cnt++;
      if (cnt == 2) v.push_back(i);
      i++;
    }
    cout << v.back();
  }
  return 0;
}

```