module Ss = Set.Make(String)

let s = read_line ()
let len = String.length s
let k = read_int ()

let f i j set =
  let sub = String.sub s i j in
  if (Ss.mem sub set) then set
  else (Ss.add sub set)

let rec inner i j set =
  if j > (len-i) || j > k then
    set
  else
    let set' = f i j set in
    inner i (succ j) set'

let rec outer i set =
  if i <= (len - 1) then
    let set' = inner i 1 set in
    outer (succ i) set'
  else
    set

let () =
  let ls = outer 0 Ss.empty |> Ss.elements in
  let ar = Array.of_list ls in
  let () = Array.fast_sort String.compare ar in
  print_endline ar.(k-1)
