fun main (args : Array<String>) {
	val (a, b, k) = readLine()!!.split(" ").map(String::toInt)
	val A : Int = a.toInt()
	val B : Int = b.toInt()
	val K : Int = k.toInt()
	var result : MutableList<Int> = mutableListOf()
	for (i in 1..100) {
		if ( (A % i == 0) && (B % i == 0) ) {
			result.add(i)
		}
	}
	result.reverse()
	println("${result[K - 1]}")
}