K = int(input())
sn_list = []
for n in range(1,10**15):
    sn = 0
    for i in str(n):
        sn += int(i)
    sn_list.append(n//sn)
sunuke_list = []
counter = 1
while(not(sn_list == [])):
    if min(sn_list) == sn_list[0]:
        sunuke_list.append(counter)
    counter += 1
    sn_list.pop(0)
print(sunuke_list[K-1])  