

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