

Input

The input contains a single integer a (1 ≤ a ≤ 30).

Output

Output a single integer.

Example

Input

3


Output

27
#include <bits/stdc++.h>
using namespace std;
int num(int x) {
  int t = 0;
  while (x > 0) {
    t += x % 10;
    x /= 10;
  }
  return t;
}
int main() {
  int n;
  scanf("%d", &n);
  int i = 1;
  int k = 0;
  while (1) {
    int a = num(i);
    int l = i;
    int i1 = 2;
    int b = 0;
    while (l > 1) {
      if (l % i1 == 0) {
        while (l % i1 == 0) {
          l /= i1;
          b += num(i1);
        }
      }
      i1++;
    }
    if (a == b && i1 - 1 != i) k++;
    if (k == n) {
      printf("%d\n", i);
      break;
    }
    i++;
  }
  return 0;
}
