c = 0
K = int(input())
for i in range(1,10):
    c += 1
    if c == K:
        print(i)

for i in range(1,10):
    for j in range(i-1,min(i+2,10)):
        c += 1
        if c == K:
            print(10*i+j)

for i in range(1,10):
    for j in range(i-1,min(i+2,10)):
        for k in range(max(j-1,0),min(j+2,10)):
            c += 1
            if c == K:
                print(100*i+10*j+k)

for i in range(1,10):
    for j in range(i-1,min(i+2,10)):
        for k in range(max(j-1,0),min(j+2,10)):
            for l in range(max(k-1,0),min(k+2,10)):
                c += 1
                if c == K:
                    print(1000*i+100*j+10*k+l)

for i in range(1,10):
    for j in range(i-1,min(i+2,10)):
        for k in range(max(j-1,0),min(j+2,10)):
            for l in range(max(k-1,0),min(k+2,10)):
                for m in range(max(l-1,0),min(l+2,10)):
                    c += 1
                    if c == K:
                        print(10000*i+1000*j+100*k+10*l+m)

for i in range(1,10):
    for j in range(i-1,min(i+2,10)):
        for k in range(max(j-1,0),min(j+2,10)):
            for l in range(max(k-1,0),min(k+2,10)):
                for m in range(max(l-1,0),min(l+2,10)):
                    for n in range(max(m-1,0),min(m+2,10)):
                        c += 1
                        if c == K:
                            print(100000*i+10000*j+1000*k+100*l+10*m+n)

for i in range(1,10):
    for j in range(i-1,min(i+2,10)):
        for k in range(max(j-1,0),min(j+2,10)):
            for l in range(max(k-1,0),min(k+2,10)):
                for m in range(max(l-1,0),min(l+2,10)):
                    for n in range(max(m-1,0),min(m+2,10)):
                        for o in range(max(n-1,0),min(n+2,10)):
                            c += 1
                            if c == K:
                                print(1000000*i+100000*j+10000*k+1000*l+100*m+10*n+o)

for i in range(1,10):
    for j in range(i-1,min(i+2,10)):
        for k in range(max(j-1,0),min(j+2,10)):
            for l in range(max(k-1,0),min(k+2,10)):
                for m in range(max(l-1,0),min(l+2,10)):
                    for n in range(max(m-1,0),min(m+2,10)):
                        for o in range(max(n-1,0),min(n+2,10)):
                            for q in range(max(o-1,0),min(o+2,10)):
                                c += 1
                                if c == K:
                                    print(10000000*i+1000000*j+100000*k+10000*l+1000*m+100*n+10*o+q)

for i in range(1,10):
    for j in range(i-1,min(i+2,10)):
        for k in range(max(j-1,0),min(j+2,10)):
            for l in range(max(k-1,0),min(k+2,10)):
                for m in range(max(l-1,0),min(l+2,10)):
                    for n in range(max(m-1,0),min(m+2,10)):
                        for o in range(max(n-1,0),min(n+2,10)):
                            for q in range(max(o-1,0),min(o+2,10)):
                                for t in range(max(q-1,0),min(q+2,10)):
                                    c += 1
                                    if c == K:
                                        print(100000000*i+10000000*j+1000000*k+100000*l+10000*m+1000*n+100*o+10*q+t)

for i in range(1,10):
    for j in range(i-1,min(i+2,10)):
        for k in range(max(j-1,0),min(j+2,10)):
            for l in range(max(k-1,0),min(k+2,10)):
                for m in range(max(l-1,0),min(l+2,10)):
                    for n in range(max(m-1,0),min(m+2,10)):
                        for o in range(max(n-1,0),min(n+2,10)):
                            for q in range(max(o-1,0),min(o+2,10)):
                                for t in range(max(q-1,0),min(q+2,10)):
                                    for y in range(max(t-1,0),min(t+2,10)):
                                        c += 1
                                        if c == K:
                                            print(1000000000*i+100000000*j+10000000*k+1000000*l+100000*m+10000*n+1000*o+100*q+10*t+y)

Measured memory_bytes: 55792