s = eval(input())

l_s = list(s)

K = int(eval(input()))

if K == 1:print((min(l_s)));exit()

elif K == 2:

    idx = s.index(min(l_s))

    if idx < len(s)-1:

        print((s[idx:idx+2]))

    else:

        print((sorted(l_s)[1]))

    exit()

sub = {s}

for d in range(1,6):

    for i in range(len(s)-d+1):

        sub |= {s[i:i+d]}

sub = list(sub)

n = len(sub)

for i in range(K):

    for j in range(n-i):

        a, b = sub[-i-1], sub[j]

        if a > b: sub[-i-1], sub[j] = b, a

print((sub[-K]))
s = eval(input())

n = len(s)

K = int(eval(input()))



chars = sorted(set(s))

lexicon = []



def next_word(cur):

    lexicon.append(cur)

    if len(lexicon) < K:

        for next_c in chars:

            next_w = cur + next_c

            if next_w in s:

                return next_word(next_w)



for char in chars:

    next_word(char)



print((lexicon[K-1]))
s = eval(input())
l_s = list(s)
K = int(eval(input()))
if K == 1:
    print((min(l_s)))
    exit()
elif K == 2:
    idx = s.index(min(l_s))
    if idx < len(s) - 1:
        print((s[idx : idx + 2]))
    else:
        print((sorted(l_s)[1]))
    exit()
sub = {s}
for d in range(1, 6):
    for i in range(len(s) - d + 1):
        sub |= {s[i : i + d]}
sub = list(sub)
n = len(sub)
for i in range(K):
    for j in range(n - i):
        a, b = sub[-i - 1], sub[j]
        if a > b:
            sub[-i - 1], sub[j] = b, a
print((sub[-K]))

s = eval(input())
n = len(s)
K = int(eval(input()))
chars = sorted(set(s))
lexicon = []


def next_word(cur):
    lexicon.append(cur)
    if len(lexicon) < K:
        for next_c in chars:
            next_w = cur + next_c
            if next_w in s:
                return next_word(next_w)


for char in chars:
    next_word(char)
print((lexicon[K - 1]))

-l_s = list(s) +n = len(s) -if K == 1: -    print((min(l_s))) -    exit() -elif K == 2: -    idx = s.index(min(l_s)) -    if idx < len(s) - 1: -        print((s[idx : idx + 2])) -    else: -        print((sorted(l_s)[1])) -    exit() -sub = {s} -for d in range(1, 6): -    for i in range(len(s) - d + 1): -        sub |= {s[i : i + d]} -sub = list(sub) -n = len(sub) -for i in range(K): -    for j in range(n - i): -        a, b = sub[-i - 1], sub[j] -        if a > b: -            sub[-i - 1], sub[j] = b, a -print((sub[-K])) +chars = sorted(set(s)) +lexicon = [] + + +def next_word(cur): +    lexicon.append(cur) +    if len(lexicon) < K: +        for next_c in chars: +            next_w = cur + next_c +            if next_w in s: +                return next_word(next_w) + + +for char in chars: +    next_word(char) +print((lexicon[K - 1]))