Buggy python submission (verdict: Time Limit Exceeded):
s = input()

d = ["z"*5010]*5

for i in range(len(s)):
    for j in range(i, len(s)):
        x = s[i:j+1]
        if x in d or x == '':
            continue
        k = 0
        while k < 5 and x > d[k]:
            k += 1
        # print(k, d[0:k], x, d[k:])
        if k < 5:
            d = d[0:k] + [x] + d[k:]
            d = d[0:5]
        # print(f"->{d}")
# l = list(d)
# l.sort()
# print(l)
# if l[0] == '':
    # l = l[1:]

k = int(input())
print(d[k-1])


Fixed submission:
s = input()

d = ["z"*5010]*5

k = int(input())
for i in range(len(s)):
    for j in range(i, i+k):
        x = s[i:j+1]
        if x in d or x == '':
            continue
        l = 0
        while l < 5 and x > d[l]:
            l += 1
        # print(k, d[0:k], x, d[k:])
        if l < 5:
            d = d[0:l] + [x] + d[l:]
            d = d[0:5]
        # print(f"->{d}")
# l = list(d)
# l.sort()
# print(l)
# if l[0] == '':
    # l = l[1:]

print(d[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

d = ["z"*5010]*5

for i in range(len(s)):
    for j in range(i, len(s)):
        x = s[i:j+1]
        if x in d or x == '':
            continue
        k = 0
        while k < 5 and x > d[k]:
            k += 1
        # print(k, d[0:k], x, d[k:])
        d = d[0:k] + [x] + d[k:]
        d = d[0:5]
        # print(f"->{d}")
# l = list(d)
# l.sort()
# print(l)
# if l[0] == '':
    # l = l[1:]

k = int(input())
print(d[k-1])


Fixed submission:
s = input()

d = ["z"*5010]*5

k = int(input())
for i in range(len(s)):
    for j in range(i, i+k):
        x = s[i:j+1]
        if x in d or x == '':
            continue
        l = 0
        while l < 5 and x > d[l]:
            l += 1
        # print(k, d[0:k], x, d[k:])
        if l < 5:
            d = d[0:l] + [x] + d[l:]
            d = d[0:5]
        # print(f"->{d}")
# l = list(d)
# l.sort()
# print(l)
# if l[0] == '':
    # l = l[1:]

print(d[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())

d = set()

for i in range(len(s)):
    for j in range(i,len(s)):
        d.add(s[i:j + 1])
l = list(d)
l.sort()
# print(l)
if l[0] == '':
    l = l[1:]

print(l[k-1])


Fixed submission:
s = input()

d = ["z"*5010]*5

k = int(input())
for i in range(len(s)):
    for j in range(i, i+k):
        x = s[i:j+1]
        if x in d or x == '':
            continue
        l = 0
        while l < 5 and x > d[l]:
            l += 1
        # print(k, d[0:k], x, d[k:])
        if l < 5:
            d = d[0:l] + [x] + d[l:]
            d = d[0:5]
        # print(f"->{d}")
# l = list(d)
# l.sort()
# print(l)
# if l[0] == '':
    # l = l[1:]

print(d[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())

d = set()

for i in range(len(s)):
    for j in range(len(s)):
        d.add(s[i:j + 1])
l = list(d)
l.sort()
# print(l)
if l[0] == '':
    l = l[1:]

print(l[k-1])


Fixed submission:
s = input()

d = ["z"*5010]*5

k = int(input())
for i in range(len(s)):
    for j in range(i, i+k):
        x = s[i:j+1]
        if x in d or x == '':
            continue
        l = 0
        while l < 5 and x > d[l]:
            l += 1
        # print(k, d[0:k], x, d[k:])
        if l < 5:
            d = d[0:l] + [x] + d[l:]
            d = d[0:5]
        # print(f"->{d}")
# l = list(d)
# l.sort()
# print(l)
# if l[0] == '':
    # l = l[1:]

print(d[k-1])