

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;
vector<int> ans;
int get(int n) {
  int sum = 0, cur = n;
  while (cur != 0) {
    sum += cur % 10;
    cur /= 10;
  }
  return sum;
}
bool check(int n) {
  int sum = 0, cur = n;
  for (int i = 2; i * i <= cur; i++)
    if (cur % i == 0) {
      int cursum = get(i);
      while (cur % i == 0) {
        sum += cursum;
        cur /= i;
      }
    }
  if (cur != 1 && cur != n) sum += get(cur);
  if (sum == get(n))
    return true;
  else
    return false;
}
int main() {
  int a, i;
  cin >> a;
  for (i = 2; ans.size() != a; i++) {
    if (check(i)) ans.push_back(i);
  }
  cout << ans[a - 1];
  return 0;
}
