fun main(args: Array<String>) = println(run {
    tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
    fun divisors(x: Int): List<Long> = (1..Math.sqrt(x.toDouble()).toLong()).asSequence().filter { x % it == 0L }.map { listOf(it, x / it) }.flatten().distinct().sorted().toList()

    val (a,b,k) = readLine()!!.split(" ").map { it.toInt() }
    divisors(gcd(a, b)).sortedDescending()[k-1]
})
