character(5000) :: s
integer :: k,lens
character(5),allocatable :: store(:)
character(5) :: ans
integer :: i,j,kk,l
read *,s
read *,k
lens = len_trim(s)
allocate(store(k*lens))

kk = 0
do i  = 1, lens
   do j = 0, k-1
      l = i + j
      if (l > lens) exit
      kk = kk + 1
      store(kk) = s(i:l)
   enddo
enddo

call cs11(kk, store)

i = 1
j = 1
ans = store(1)
do while (i < k)
   j = j + 1
   if (store(j) /= ans) then
      i = i + 1
      ans = store(j)
   endif
enddo

print '(a)',ans
stop

contains

subroutine cs11(Ncomb,a)
   integer, intent(in) :: Ncomb
   character(5), intent(inout) :: a(Ncomb)
   integer :: icomb, jcomb
   character(5) :: rswp
   logical :: flg_swp

   icomb = Ncomb
   flg_swp = .false.
   do while (icomb > 1 .or. flg_swp)
      icomb = (icomb * 10) / 13
      if (icomb < 1) then
         icomb = 1
      else if (icomb == 9 .or. icomb == 10) then 
         icomb = 11
      endif
      flg_swp = .false.
      do jcomb = 1, Ncomb-icomb
         if (a(jcomb) > a(jcomb+icomb)) then
            rswp = a(jcomb) 
            a(jcomb) = a(jcomb+icomb)
            a(jcomb+icomb) = rswp
            flg_swp = .true.
         endif
      enddo
   enddo
endsubroutine cs11
end