import java.util.*

fun main(args: Array<String>) {
    val s = Scanner(System.`in`)
    val a = s.nextInt()
    val b = s.nextInt()
    val k = s.nextInt()

    val pa = (1..a).filter { a % it == 0 }
    val pb = (1..b).filter { b % it == 0 }
    val ret = pa.intersect(pb).sortedDescending()[k - 1]
    println(ret)
}