# your code goes here
import re
def find_n_nums(n):
very_big_number = 1e12
min_sum = very_big_number
for i in range(1,23):
#print('looking for sum',i)
val = min_num_with_sum(i)
#print('starting from',val)
s = val
for _ in range(n-1):
val = next_num_with_sum(val)
#print(val,end=' ')
s += val
if s>very_big_number:
break
#print('digit sum',i,'number sum',s)
min_sum = min(min_sum,s)
return min_sum
def min_num_with_sum(s):
if s<10:
return s
elif s<19:
return (s-9)*10+9
else:
return (s-18)*100+99
def next_num_with_sum(v):
#print('want to find next to',v)
v = str(v)
#looking for 'XXXX9999X0000' pattern
match = re.search(r'9*\d?0*$',v)
#print('match is',match)
v = [0]+[int(d) for d in v]
#print(v)
tail_len = len(match.group(0)) #at least 1
tail_sum = sum(v[-tail_len:]) - 1
#print('v',v,'tail sum=',tail_sum,end=' ')
v[-tail_len-1] += 1 #it is not 9
new_tail = [int(d) for d in str(min_num_with_sum(tail_sum))]
#print(new_tail)
new_tail = [0]*(tail_len-len(new_tail))+new_tail
#print('new_tail',new_tail)
v[-tail_len:] = new_tail
#print('v',v,int(''.join(str(d) for d in v)))
return int(''.join(str(d) for d in v))
n = int(input())
print(find_n_nums(n))
IyB5b3VyIGNvZGUgZ29lcyBoZXJlCmltcG9ydCByZQoKZGVmIGZpbmRfbl9udW1zKG4pOgoJdmVyeV9iaWdfbnVtYmVyID0gMWUxMgoJCgltaW5fc3VtID0gdmVyeV9iaWdfbnVtYmVyCglmb3IgaSBpbiByYW5nZSgxLDIzKToKCQkjcHJpbnQoJ2xvb2tpbmcgZm9yIHN1bScsaSkKCQl2YWwgPSBtaW5fbnVtX3dpdGhfc3VtKGkpCgkJI3ByaW50KCdzdGFydGluZyBmcm9tJyx2YWwpCgkJcyA9IHZhbAoJCWZvciBfIGluIHJhbmdlKG4tMSk6CgkJCXZhbCA9IG5leHRfbnVtX3dpdGhfc3VtKHZhbCkKCQkJI3ByaW50KHZhbCxlbmQ9JyAnKQoJCQlzICs9IHZhbAoJCQlpZiBzPnZlcnlfYmlnX251bWJl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