#include <bits/stdc++.h>
using namespace std;
int a[5] = {2, 3, 1, 2, 1};
bool prime[10000000];
bool isok(int i) {
  int c = i;
  if (!prime[i]) return 0;
  string s = "";
  while (i) {
    s += (char)('0' + i % 10);
    i /= 10;
  }
  for (int j = 0; j < s.length(); j++) i = i * 10 + int(s[j] - '0');
  if (c == i) return 0;
  if (!prime[i]) return 0;
  return 1;
}
int main() {
  for (int i = 0; i < 5000000; i++) prime[i] = 1;
  prime[0] = prime[1] = 0;
  for (int i = 2; i * i < 5000000; i++)
    for (int j = i + i; j < 5000000 && prime[i]; j += i) prime[j] = 0;
  int n;
  cin >> n;
  int p = 0;
  for (int i = 0; i < 5000000; i++) {
    if (isok(i)) p++;
    if (p == n) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

### Prompt

Please formulate 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>
using namespace std;
int a[5] = {2, 3, 1, 2, 1};
bool prime[10000000];
bool isok(int i) {
  int c = i;
  if (!prime[i]) return 0;
  string s = "";
  while (i) {
    s += (char)('0' + i % 10);
    i /= 10;
  }
  for (int j = 0; j < s.length(); j++) i = i * 10 + int(s[j] - '0');
  if (c == i) return 0;
  if (!prime[i]) return 0;
  return 1;
}
int main() {
  for (int i = 0; i < 5000000; i++) prime[i] = 1;
  prime[0] = prime[1] = 0;
  for (int i = 2; i * i < 5000000; i++)
    for (int j = i + i; j < 5000000 && prime[i]; j += i) prime[j] = 0;
  int n;
  cin >> n;
  int p = 0;
  for (int i = 0; i < 5000000; i++) {
    if (isok(i)) p++;
    if (p == n) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

```