#include <bits/stdc++.h>
using namespace std;
bool F(int x) {
  int n, i, n1;
  int t = 0;
  int y = x;
  while (y) {
    t *= 10;
    t += y % 10;
    y /= 10;
  }
  if (x == t) return false;
  n = sqrt(x);
  for (i = 2; i <= n; i++)
    if (!(x % i)) return false;
  n1 = sqrt(t);
  for (i = 2; i <= n1; i++)
    if (!(t % i)) return false;
  return true;
}
int main() {
  int x = 0, i, n;
  cin >> n;
  for (i = 10; i; i++) {
    if (F(i)) {
      x++;
      if (x == n) {
        cout << i << endl;
        return 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;
bool F(int x) {
  int n, i, n1;
  int t = 0;
  int y = x;
  while (y) {
    t *= 10;
    t += y % 10;
    y /= 10;
  }
  if (x == t) return false;
  n = sqrt(x);
  for (i = 2; i <= n; i++)
    if (!(x % i)) return false;
  n1 = sqrt(t);
  for (i = 2; i <= n1; i++)
    if (!(t % i)) return false;
  return true;
}
int main() {
  int x = 0, i, n;
  cin >> n;
  for (i = 10; i; i++) {
    if (F(i)) {
      x++;
      if (x == n) {
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}

```