import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

auto gcd(T)(T m, T n) {
	if(n == 0) {
		return m;
	}
	if(n > m) {
		return gcd(n, m);
	}
	return gcd(n, m % n);
}

void main() {
	auto nums = readNums();
	auto a = nums[0];
	auto b = nums[1];
	auto k = nums[2];
	auto d = gcd(a, b);
	
	auto n = d;
	auto div = d;
	for(size_t count = 0; count < k; --n) {
		if(d % n == 0) {
			++count;
			div = n;
		}
	}
	writefln("%s", div);
}
