unittest
{
	assert( [ "aba", "4" ].solve == "b" );
	assert( [ "atcoderandatcodeer", "5" ].solve == "andat" );
	assert( [ "z", "1" ].solve == "z" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	input.popFront;
	auto k = input.front.to!( long );
	
	bool[ dstring ] ks;
	foreach( i; 1L .. 5 + 1 )
	{
		foreach( j; 0L .. s.length.signed - i + 1 )
		{
			ks[ s[ j .. j + i ].idup ] = true;
		}
	}
	return ks.keys.sort().drop( k - 1 ).front;
}
