import java.math.*

fun main(args: Array<String>) {
    val (A, B, K) = readInputLine().split(" ").map{it.toInt()}
    
    var cnt = 0
    
    for (i in Math.min(A, B) downTo 1) {
        if (A % i == 0 && B % i == 0) {
            if (++cnt == K) {
                println(i)
                return
            }
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}
