n = int(eval(input()))

l = [_ for _ in range(1,10)]



for i in range(10**5):

    if str(l[i])[-1] == '0':

        l.append(l[i]*10 + int(str(l[i])[-1]))

        l.append(l[i]*10 + int(str(l[i])[-1]) + 1)



    elif str(l[i])[-1] == '9':

        l.append(l[i]*10 + int(str(l[i])[-1]) - 1)

        l.append(l[i]*10 + int(str(l[i])[-1]))



    else:

        l.append(l[i]*10 + int(str(l[i])[-1]) - 1)

        l.append(l[i]*10 + int(str(l[i])[-1]))

        l.append(l[i]*10 + int(str(l[i])[-1]) + 1)



print((l[n-1]))
n = int(eval(input()))

l = [_ for _ in range(1,10)]



cnt = 9

for i in range(10**5):

    if cnt >= n:

        break

    if str(l[i])[-1] == '0':

        l.append(l[i]*10 + int(str(l[i])[-1]))

        l.append(l[i]*10 + int(str(l[i])[-1]) + 1)

        cnt += 2



    elif str(l[i])[-1] == '9':

        l.append(l[i]*10 + int(str(l[i])[-1]) - 1)

        l.append(l[i]*10 + int(str(l[i])[-1]))

        cnt += 2



    else:

        l.append(l[i]*10 + int(str(l[i])[-1]) - 1)

        l.append(l[i]*10 + int(str(l[i])[-1]))

        l.append(l[i]*10 + int(str(l[i])[-1]) + 1)

        cnt += 3



print((l[n-1]))
n = int(eval(input()))
l = [_ for _ in range(1, 10)]
for i in range(10**5):
    if str(l[i])[-1] == "0":
        l.append(l[i] * 10 + int(str(l[i])[-1]))
        l.append(l[i] * 10 + int(str(l[i])[-1]) + 1)
    elif str(l[i])[-1] == "9":
        l.append(l[i] * 10 + int(str(l[i])[-1]) - 1)
        l.append(l[i] * 10 + int(str(l[i])[-1]))
    else:
        l.append(l[i] * 10 + int(str(l[i])[-1]) - 1)
        l.append(l[i] * 10 + int(str(l[i])[-1]))
        l.append(l[i] * 10 + int(str(l[i])[-1]) + 1)
print((l[n - 1]))

n = int(eval(input()))
l = [_ for _ in range(1, 10)]
cnt = 9
for i in range(10**5):
    if cnt >= n:
        break
    if str(l[i])[-1] == "0":
        l.append(l[i] * 10 + int(str(l[i])[-1]))
        l.append(l[i] * 10 + int(str(l[i])[-1]) + 1)
        cnt += 2
    elif str(l[i])[-1] == "9":
        l.append(l[i] * 10 + int(str(l[i])[-1]) - 1)
        l.append(l[i] * 10 + int(str(l[i])[-1]))
        cnt += 2
    else:
        l.append(l[i] * 10 + int(str(l[i])[-1]) - 1)
        l.append(l[i] * 10 + int(str(l[i])[-1]))
        l.append(l[i] * 10 + int(str(l[i])[-1]) + 1)
        cnt += 3
print((l[n - 1]))

+cnt = 9 +    if cnt >= n: +        break +        cnt += 2 +        cnt += 2 +        cnt += 3