

Input

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

Output

Output a single integer.

Example

Input

3


Output

27
a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}
print(a[int(input())])