import kotlin.math.max
import kotlin.math.min

fun main() {
    val (A, B, K) = readLine()!!.split(" ").map { it.toInt() }
    val C = min(A, B)
    var list = mutableListOf<Int>()

    for (i in 1..(C/2)) {
        if (A % i == 0 && B % i == 0) {
            list.add(i)
        }
    }

    if (max(A, B) % C == 0) {
        list.add(C)
    }

    val ans = list.sortedDescending()[K-1]

    println(ans)
}