from sys import stdin

from string import ascii_lowercase





def myfind(s, c):

    result = []

    for i, x in enumerate(s):

        if x == c:

            result.append(i)

    return result





def main():

    s = stdin.readline().rstrip()

    K = int(stdin.readline().rstrip())

    result = []

    for x in ascii_lowercase:

        idxs = myfind(s, x)

        if not idxs:

            continue

        result.append(x)

        if len(result) >= K:

            break

        temp = sorted(list(set([s[x:] for x in idxs])))

        for y in temp:

            for z in range(len(y)):

                foo = y[: z + 1]

                if not foo in result:

                    result.append(foo)

                    if len(result) >= K:

                        break

            if len(result) >= K:

                break

        if len(result) >= K:

            break



    print((result[-1]))





if __name__ == '__main__':

    main()

from sys import stdin

from string import ascii_lowercase





def main():

    s = stdin.readline().rstrip()

    K = int(stdin.readline().rstrip())

    result = []

    for c in ascii_lowercase:

        for text in sorted([s[i:] for i, x in enumerate(s) if x == c]):

            for i in range(len(text)):

                if not text[:i + 1] in result:

                    result.append(text[:i + 1])

                    if len(result) == K:

                        print((result[-1]))

                        return





if __name__ == '__main__':

    main()

from sys import stdin
from string import ascii_lowercase


def myfind(s, c):
    result = []
    for i, x in enumerate(s):
        if x == c:
            result.append(i)
    return result


def main():
    s = stdin.readline().rstrip()
    K = int(stdin.readline().rstrip())
    result = []
    for x in ascii_lowercase:
        idxs = myfind(s, x)
        if not idxs:
            continue
        result.append(x)
        if len(result) >= K:
            break
        temp = sorted(list(set([s[x:] for x in idxs])))
        for y in temp:
            for z in range(len(y)):
                foo = y[: z + 1]
                if not foo in result:
                    result.append(foo)
                    if len(result) >= K:
                        break
            if len(result) >= K:
                break
        if len(result) >= K:
            break
    print((result[-1]))


if __name__ == "__main__":
    main()

from sys import stdin
from string import ascii_lowercase


def main():
    s = stdin.readline().rstrip()
    K = int(stdin.readline().rstrip())
    result = []
    for c in ascii_lowercase:
        for text in sorted([s[i:] for i, x in enumerate(s) if x == c]):
            for i in range(len(text)):
                if not text[: i + 1] in result:
                    result.append(text[: i + 1])
                    if len(result) == K:
                        print((result[-1]))
                        return


if __name__ == "__main__":
    main()

- - -def myfind(s, c): -    result = [] -    for i, x in enumerate(s): -        if x == c: -            result.append(i) -    return result -    for x in ascii_lowercase: -        idxs = myfind(s, x) -        if not idxs: -            continue -        result.append(x) -        if len(result) >= K: -            break -        temp = sorted(list(set([s[x:] for x in idxs]))) -        for y in temp: -            for z in range(len(y)): -                foo = y[: z + 1] -                if not foo in result: -                    result.append(foo) -                    if len(result) >= K: -                        break -            if len(result) >= K: -                break -        if len(result) >= K: -            break -    print((result[-1])) +    for c in ascii_lowercase: +        for text in sorted([s[i:] for i, x in enumerate(s) if x == c]): +            for i in range(len(text)): +                if not text[: i + 1] in result: +                    result.append(text[: i + 1]) +                    if len(result) == K: +                        print((result[-1])) +                        return