program atcoder
    implicit none
    integer :: k,i,j,l
    character :: s*5008,ans(5)*6
    read*,s,k
    ans = "zzzzz"
    l = len(trim(s))
    do i=1,l
        do j=1,5
            if( any(ans==s(i:i+j-1)) .or. l<i+j-1 )then
                cycle
            endif
            if(s(i:i+j-1)<ans(1))then
                ans(5) = ans(4)
                ans(4) = ans(3)
                ans(3) = ans(2)
                ans(2) = ans(1)
                ans(1) = s(i:i+j-1)
            else if(s(i:i+j-1)<ans(2))then
                ans(5) = ans(4)
                ans(4) = ans(3)
                ans(3) = ans(2)
                ans(2) = s(i:i+j-1)
            else if(s(i:i+j-1)<ans(3))then
                ans(5) = ans(4)
                ans(4) = ans(3)
                ans(3) = s(i:i+j-1)
            else if(s(i:i+j-1)<ans(4))then
                ans(5) = ans(4)
                ans(4) = s(i:i+j-1)
            else if(s(i:i+j-1)<ans(5))then
                ans(5) = s(i:i+j-1)
            endif
        enddo
    enddo
    write(*,'(a)')ans(k)
    stop 
contains
end program atcoder