

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 main() {
  int a;
  cin >> a;
  switch (a) {
    case 1:
      cout << 4;
      break;
    case 2:
      cout << 22;
      break;
    case 3:
      cout << 27;
      break;
    case 4:
      cout << 58;
      break;
    case 5:
      cout << 85;
      break;
    case 6:
      cout << 94;
      break;
    case 7:
      cout << 121;
      break;
    case 8:
      cout << 166;
      break;
    case 9:
      cout << 202;
      break;
    case 10:
      cout << 265;
      break;
    case 11:
      cout << 274;
      break;
    case 12:
      cout << 319;
      break;
    case 13:
      cout << 346;
      break;
    case 14:
      cout << 355;
      break;
    case 15:
      cout << 378;
      break;
    case 16:
      cout << 382;
      break;
    case 17:
      cout << 391;
      break;
    case 18:
      cout << 438;
      break;
    case 19:
      cout << 454;
      break;
    case 20:
      cout << 483;
      break;
    case 21:
      cout << 517;
      break;
    case 22:
      cout << 526;
      break;
    case 23:
      cout << 535;
      break;
    case 24:
      cout << 562;
      break;
    case 25:
      cout << 576;
      break;
    case 26:
      cout << 588;
      break;
    case 27:
      cout << 627;
      break;
    case 28:
      cout << 634;
      break;
    case 29:
      cout << 636;
      break;
    case 30:
      cout << 645;
      break;
  }
}
