program arc097_a
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,l,r,k
    character(5000):: s, s_list(5),subs

    read*, s
    read*, k
    s_list(:) = ''
    do i=1,5
        do j=1,k
            s_list(i) = trim(s_list(i)) // 'z'
        end do
    end do
    n = len_trim(s)
    
    do l=1,n
        do r=l,min(l+k,n)
            subs = s(l:r)
            do i=1,5
                if (subs == s_list(i)) exit
                if (subs < s_list(i)) call swap(subs, s_list(i))
            end do
        end do
    end do
    print'(a)', trim(s_list(k))
contains
    subroutine swap(s1,s2)
        character(5000):: s1,s2,tmp
        tmp=s1; s1=s2; s2=tmp
    end subroutine

end program arc097_a