program dm
    implicit none
    integer::K
    integer::KAZU(10,0:9)
    integer::SOWA(0:10)
    integer::i,j
    integer::KETA,CHECK
    read*,K
    KAZU(1,:)=1
    do i=2,10
        do j=0,9
            if(j==0)then
                KAZU(i,j)=KAZU(i-1,j)+KAZU(i-1,j+1)
            else if(j==9)then
                KAZU(i,j)=KAZU(i-1,j-1)+KAZU(i-1,j)
            else
                KAZU(i,j)=KAZU(i-1,j-1)+KAZU(i-1,j)+KAZU(i-1,j+1)
            endif
        end do
    end do
    SOWA(0)=0
    do i=1,10
        SOWA(i)=sum(KAZU(i,:))-KAZU(i,0)
    end do
    do i=1,9
        SOWA(i+1)=SOWA(i+1)+SOWA(i)
    end do
    do i=1,10
        if(K<=SOWA(i))then
            CHECK=SOWA(i-1)
            do j=1,9
                if(CHECK+KAZU(i,j)>=K)then
                    write(*,"(i0)",advance="no")j
                    call solve(K-CHECK,i-1,j)
                    stop
                endif
                CHECK= CHECK+KAZU(i,j)
            end do
        end if
    end do
contains
recursive subroutine solve(K,KU,MAE)
    integer::K,KU,MAE
    integer::tmp
    integer::i
    if(KU==0)then
        write(*,*)
        return
    endif
    tmp=0
    do i=max(0,MAE-1),min(9,MAE+1)
        if(tmp+KAZU(KU,i)>=K)then
            write(*,"(i0)",advance="no")i
            call solve(K-tmp,KU-1,i)
            stop
        endif
        tmp=tmp+KAZU(KU,i)
    end do
end subroutine
end program dm