unittest
{
	assert( [ "8 12 2" ].parse.expand.solve == 2 );
	assert( [ "100 50 4" ].parse.expand.solve == 5 );
	assert( [ "1 1 1" ].parse.expand.solve == 1 );
}



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

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abk = input.front.split.to!( long[] );
	return tuple( abk[ 0 ], abk[ 1 ], abk[ 2 ] );
}

auto solve( long a, long b, long k )
{
	auto c = 0L;
	for( auto i = min( a, b ); 0 < i; i-- )
	{
		c += ( a % i == 0 && b % i == 0 );
		if( c == k ) return i;
	}
	
	assert( false );
}
