fun gcd(a: Int, b: Int): Int {
    var x = a
    var y = b
    while (true) {
        if (y < x) {
            val z = x
            x = y
            y = z
        }
        if (x == 0) break
        y %= x
    }
    return y
}

fun divisors(n: Int): List<Int> {
    if (n == 0) return emptyList()
    if (n == 1) return listOf(n)
    val div = mutableListOf(1)
    for (i in 2..(n shr 1)) {
        if (n % i == 0) div += i
    }
    div += n
    return div
}

fun main(args: Array<String>) {
    val (a, b, k) = readLine()!!.split(' ').map(String::toInt)
    val gcd = gcd(a, b)
    val d = divisors(gcd)
    println(d[d.size - k])
}
