function main(arg) {
	arg = arg.split("\n")[0].split(" ").map(Number)
	var a = arg[0]
	var b = arg[1]
	var k = arg[2]

	var result = []
	var max = (a > b) ? b : a

	for (var i = 0; i <= max; i++) {
		if (a % i === 0 && b % i === 0) {
			result.push(i)
		}
	}
	result = result.sort((a,b) => b - a)
	console.log(result[k - 1])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));