k = int(input())
if k < 10:
    print(k)
    exit()

def s(n):
    return sum(list(map(int, str(n))))

seeds = [i for i in range(2, 9)]
for i in range(16):
    for j in range(1, 10):
        for k in range(10):
            seeds.append((k + j*10) * 10**i)

# print(seeds)

seeds = list(map(lambda x:x-1, seeds))

l = []
for i in seeds:
    l.append([i, s(i), i/s(i)])
#
l.sort(key=lambda x:x[2])
# for i in range(len(l)):
#     print(l[i])

max = 0
ans = []
for i in range(len(l)):
    if l[i][0] > max:
        max = l[i][0]
        ans.append(l[i][0])
        # print(l[i][0], end=" ")

print(ans[k-1])

# max = 0
# for i in range(len(l)):
#     if l[i][0] > max:
#         max = l[i][0]
#         print(l[i][0]+1, end=" ")
# print()
