local s = io.read()
local k = io.read("*n")
local n = #s
local d = {}
local t = {}
local sub = ""
for i = 1, n do
  local lenmax = math.min(k, n - i + 1)
  for j = 1, lenmax do
    sub = s:sub(i, i + j - 1)
    if d[sub] == nil then
      d[sub] = true
      table.insert(t, sub)
    end
  end
end
table.sort(t)
print(t[k])
