

Input

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

Output

Output a single integer.

Example

Input

3


Output

27

n = int(raw_input())

if(n==1):
	print '4'

elif(n==2):
	print '22'

elif(n==3):
	print '27'

elif(n==4):
	print '58'

elif(n==5):
	print '85'

elif(n==6):
	print '94'

elif(n==7):
	print '121'

elif(n==8):
	print '166'

elif(n==9):
	print '202'

elif(n==10):
	print '265'

elif(n==11):
	print '274'

elif(n==12):
	print '319'

elif(n==13):
	print '346'

elif(n==14):
	print '355'

elif(n==15):
	print '378'

elif(n==16):
	print '382'

elif(n==17):
	print '391'

elif(n==18):
	print '438'

elif(n==19):
	print '454'

elif(n==20):
	print '483'

elif(n==21):
	print '517'

elif(n==22):
	print '526'

elif(n==23):
	print '535'

elif(n==24):
	print '562'

elif(n==25):
	print '576'

elif(n==26):
	print '588'

elif(n==27):
	print '627'

elif(n==28):
	print '634'

elif(n==29):
	print '636'

elif(n==30):
	print '645'
