import java.util.*

private fun readInts() = readLine()!!.split(" ").map { it.toInt() }
private fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
private fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V> = LinkedHashMap(this)
private fun <K, V> mutableMapOf(): MutableMap<K, V> = LinkedHashMap()
private fun <K, V> mutableMapOf(vararg pairs: Pair<K, V>) = pairs.toMap().toMutableMap()

fun main(args: Array<String>) {
    val (A, B, K) = readInts()

    val setA = mutableSetOf(1)
    val setB = mutableSetOf(1)
    for (a in 1 until A) if (A % a == 0) setA.add(A / a)
    for (b in 1 until B) if (B % b == 0) setB.add(B / b)

    println(setA.intersect(setB).sorted().reversed().drop(K - 1).first())
}