#include <bits/stdc++.h>
using namespace std;
int fz(int k);
bool prime(int i);
bool su[1000000];
int num[1000000];
int ans[1000000];
int main() {
  int n, x = 0, y = 0;
  cin >> n;
  for (int i = 2; i * i < 1000000; i++) {
    if (su[i] == 0) {
      for (int j = 2; j <= 1000000 / i; j++) su[i * j] = 1;
    }
  }
  for (int i = 2; i <= 1000000; i++) {
    if (su[i] == 0) num[++x] = i;
  }
  for (int i = 2; i <= 1000000; i++)
    if ((prime(fz(num[i]))) && (fz(num[i]) != num[i])) ans[++y] = num[i];
  cout << ans[n];
  return 0;
}
int fz(int k) {
  int sum = 0;
  while (k != 0) {
    sum = sum * 10 + k % 10;
    k /= 10;
  }
  return sum;
}
bool prime(int i) {
  int j = 2;
  while (j < sqrt(i) && i % j != 0) j++;
  if (j > sqrt(i))
    return 1;
  else
    return 0;
}

### Prompt

Create a solution in Cpp for 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 fz(int k);
bool prime(int i);
bool su[1000000];
int num[1000000];
int ans[1000000];
int main() {
  int n, x = 0, y = 0;
  cin >> n;
  for (int i = 2; i * i < 1000000; i++) {
    if (su[i] == 0) {
      for (int j = 2; j <= 1000000 / i; j++) su[i * j] = 1;
    }
  }
  for (int i = 2; i <= 1000000; i++) {
    if (su[i] == 0) num[++x] = i;
  }
  for (int i = 2; i <= 1000000; i++)
    if ((prime(fz(num[i]))) && (fz(num[i]) != num[i])) ans[++y] = num[i];
  cout << ans[n];
  return 0;
}
int fz(int k) {
  int sum = 0;
  while (k != 0) {
    sum = sum * 10 + k % 10;
    k /= 10;
  }
  return sum;
}
bool prime(int i) {
  int j = 2;
  while (j < sqrt(i) && i % j != 0) j++;
  if (j > sqrt(i))
    return 1;
  else
    return 0;
}

```