-----Input-----

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


-----Output-----

Output a single integer.


-----Example-----
Input
3

Output
27

Difficulty: MEDIUM_HARD

Starter code:

Solutions:
n = int(input())
a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]
print(a[n - 1])


l = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]
i = int(input())
print(l[i - 1])


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())])


import sys
y = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]
for line in sys.stdin:
	x = int(line.strip())
	print(y[x - 1])
	break


def sumDigits(n):
	answer = 0
	while n > 0:
		answer += n % 10
		n = n // 10
	return answer

def listFactors(n):
	answer = []
	while n > 1:
		for i in range(2, n + 1):
			if n % i == 0:
				answer.append(i)
				n = n // i
				break
	return answer
i = int(input())
test = 4
numsofar = 0
while numsofar < i:
	if len(listFactors(test)) > 1:
		numsum = sumDigits(test)
		factorsum = 0
		for factor in listFactors(test):
			factorsum += sumDigits(factor)
		if numsum == factorsum:
			numsofar += 1
			if numsofar == i:
				print(test)
				break
	test += 1


n = int(input())
k = (0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645)
x = list(k)
print(x[n])


dizi = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]
n = int(input())
print(dizi[n - 1])


a = input()
joke = dict(zip([str(i) for i in range(1, 31)], [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]))
print(joke[a])


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def main():
	a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]
	n = I()
	return a[n - 1]
print(main())


def main():
	try:
		while True:
			print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645][int(input()) - 1])
	except EOFError:
		pass
main()


import collections as col
import itertools as its
import sys
import operator
from bisect import bisect_left, bisect_right
from copy import copy, deepcopy

class Solver:

	def __init__(self):
		pass

	def solve(self):
		a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]
		x = int(input())
		print(a[x - 1])

def __starting_point():
	s = Solver()
	s.solve()
__starting_point()


n = int(input())
sieve = []
for i in range(10001):
	sieve.append(1)
sieve[0] = sieve[1] = 0
for i in range(2, 10000):
	j = 2
	while i * j <= 10000:
		sieve[i * j] = 0
		j += 1

def sumdig(x):
	ans = 0
	for i in x:
		ans += int(i)
	return ans

def primeFactors(x):
	pf = []
	for i in range(2, x // 2 + 1):
		while sieve[i] == 1 and x % i == 0:
			x //= i
			pf.append(i)
	return pf
value = 4
while True:
	compareWith = sumdig(str(value))
	pf = primeFactors(value)
	compareWhom = 0
	for i in pf:
		compareWhom += sumdig(str(i))
	if compareWhom == compareWith:
		n -= 1
	if n == 0:
		print(value)
		exit(0)
	value += 1


from math import *

def resheto(n):
	prime = [True for _ in range(n + 1)]
	prime[0] = prime[1] = False
	for i in range(2, n + 1):
		if prime[i]:
			if i ** 2 <= n:
				for j in range(i ** 2, n + 1, i):
					prime[j] = False
	answer = []
	for i in range(n + 1):
		if prime[i]:
			answer.append(i)
	return answer

class Integer(int):

	def __pow__(self, power, modulo=None):
		k = power
		bbb = 1
		c = self
		while k:
			if k % 2 == 0:
				k /= 2
				c *= c
			else:
				k -= 1
				bbb *= c
		return bbb

	def can_divide(self, n):
		if n == 0:
			return False
		elif self % n == 0:
			return True
		else:
			return False

	def trial_division(self):
		divisions = []
		d = 2
		number = self
		while number > 1:
			if number % d == 0:
				divisions.append(d)
				number /= d
			else:
				d += 1
		return sorted(divisions)

	def is_prime(self):
		if self == 2:
			return True
		j = int(sqrt(self) + 1)
		for i in range(2, j + 1):
			if self % i == 0:
				return False
		return True

	def gcd(self, bb):
		aa = self
		while bb:
			aa %= bb
			(aa, bb) = (bb, aa)
		return aa

	def lmc(self, bull):
		return int(self / gcd(self, bull) * bull)

class Matrix:

	def __init__(self, size):
		matrix = []
		for i in range(size):
			matrix.append([])
			for j in range(size):
				matrix[i].append(0)
		self.matrix = matrix
		self.n = size

	def edit_element(self, cords, new_value):
		self.matrix[cords[0]][cords[1]] = new_value

	def __add__(self, other_matrix):
		c = Matrix(self.n)
		for i in range(self.n):
			for j in range(self.n):
				c.edit_element((i, j), self.matrix[i][j] + other_matrix.matrix[i][j])
		return c

	def __mul__(self, other_matrix):
		c = Matrix(self.n)
		for i in range(self.n):
			for j in range(i):
				k = other_matrix.matrix[i][j]
				other_matrix.matrix[i][j] = other_matrix.matrix[j][i]
				other_matrix.matrix[j][i] = k
		for i in range(self.n):
			for j in range(self.n):
				c.matrix[i][j] = 0
				for k in range(self.n):
					c.matrix[i][j] += self.matrix[i][k] * other_matrix.matrix[j][k]
		for i in range(self.n):
			for j in range(i):
				k = other_matrix.matrix[i][j]
				other_matrix.matrix[i][j] = other_matrix.matrix[j][i]
				other_matrix.matrix[j][i] = k
		return c
joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]
a = int(input())
print(joke[a - 1])


ans = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]

def main():
	n = int(input())
	print(ans[n])
main()


def mp():
	return map(int, input().split())
a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]
print(a[int(input()) - 1])


n = int(input())
l = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666]
print(l[n])