'use strict'

const main = input => {
	const args = input.trim().split(' ')
	const a = parseInt(args[0], 10)
	const b = parseInt(args[1], 10)
	const k = parseInt(args[2], 10)
	let t1 = Math.max(a, b)
	const t2 = []
	
	for (let i = 0; i < t1; i++) {
		if (a % (t1 - i) === 0 && b % (t1 - i) === 0) t2.push(t1 - i)
	}

	console.log(t2[k - 1])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
