#include <bits/stdc++.h>
using namespace std;
const long long MAX = 10000000;
long long swaped(long long x) {
  long long answer = 0;
  vector<long long> vv;
  while (x > 0) {
    vv.push_back(x % 10);
    x /= 10;
  }
  long long p = pow(10, vv.size() - 1);
  for (long long i = 0; i < vv.size(); ++i) {
    answer += p * vv[i];
    p /= 10;
  }
  return answer;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long cnt = 0;
  vector<bool> prime(MAX, true);
  prime[0] = prime[1] = false;
  for (long long i = 2; i <= MAX; ++i) {
    if (prime[i])
      for (long long j = i * 1ll * i; j <= MAX; j += i) prime[j] = false;
  }
  for (long long i = 13; i <= MAX; ++i) {
    if (prime[i] && prime[swaped(i)] && i != swaped(i)) cnt++;
    if (cnt == n) return cout << i, 0;
  }
  return 0;
}

### Prompt

Please provide a cpp coded solution 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>
using namespace std;
const long long MAX = 10000000;
long long swaped(long long x) {
  long long answer = 0;
  vector<long long> vv;
  while (x > 0) {
    vv.push_back(x % 10);
    x /= 10;
  }
  long long p = pow(10, vv.size() - 1);
  for (long long i = 0; i < vv.size(); ++i) {
    answer += p * vv[i];
    p /= 10;
  }
  return answer;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long cnt = 0;
  vector<bool> prime(MAX, true);
  prime[0] = prime[1] = false;
  for (long long i = 2; i <= MAX; ++i) {
    if (prime[i])
      for (long long j = i * 1ll * i; j <= MAX; j += i) prime[j] = false;
  }
  for (long long i = 13; i <= MAX; ++i) {
    if (prime[i] && prime[swaped(i)] && i != swaped(i)) cnt++;
    if (cnt == n) return cout << i, 0;
  }
  return 0;
}

```