#import "StdIO.h"
#import "NSString-Extension.h"
#import "NSArray-Extension.h"
#import "NSMutableArray-Extension.h"
int main() {
    @autoreleasepool {
        NSArray *lines = [StdIO stringsFromStdInSeparatedByReturn];
        NSString *S = [lines objectAtIndex:0];
        NSInteger K = [lines secondInteger];
        Int L = [S length];
        if (L==1) {
            [StdIO puts:S];
            return 0;
        }
        NSMutableArray *substrs = [NSMutableArray array];
        for (Int i=0;i<L;i++) {
            for (Int j=i;j<L;j++) {
                NSString *substr = [S substringWithRange:NSMakeRange(i,j-i+1)];
                [substrs push: substr];
            }
        }
        substrs = [substrs sortedStringArrayWithAscending:YES];
        Int count = 0;
        NSString *prev = @"";
        for (NSString *str in substrs) {
            if ([prev isEqualToString:str]) {
                continue;
            }
            count++;
            if (count == K) {
                [StdIO puts: str];
                return 0;
            }
            prev = str;
        }
    }
}
