fun gcd(a: Int, b:Int):Int = if (b == 0) {a} else {gcd(b, a % b)}
fun main(args:Array<String>) {
    val (A,B,K) = readLine()!!.split(" ").map(String::toInt)

    val gcdAB = gcd(A,B)

    (1..gcdAB).filter { 
        A % it == 0 && B % it == 0
    }.sortedDescending().take(K).last().run(::println)

}
 