implicit none
integer k
integer i,j,l
character :: s*5008,ans(5)*6
read*,s,k
ans = "zzzzz"
l = len_trim(s)
do i=1,l
  do j=0,4
    if( any(ans==s(i:i+j-1)) .or. l<i+j )cycle
    if(s(i:i+j)<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)
    else if(s(i:i+j)<ans(2))then
      ans(5) = ans(4)
      ans(4) = ans(3)
      ans(3) = ans(2)
      ans(2) = s(i:i+j)
    else if(s(i:i+j)<ans(3))then
      ans(5) = ans(4)
      ans(4) = ans(3)
      ans(3) = s(i:i+j)
    else if(s(i:i+j)<ans(4))then
      ans(5) = ans(4)
      ans(4) = s(i:i+j)
    else if(s(i:i+j)<ans(5))then
      ans(5) = s(i:i+j)
    endif
  enddo
enddo

print'(a)',ans(k)
end