import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val A = sc.nextInt()
    val B = sc.nextInt()
    val K = sc.nextInt()
    val list = mutableListOf<Int>()
    for (i in Math.max(A,B) downTo 1) {
        if (A%i != 0) continue
        if (B%i != 0) continue
        list.add(i)
    }
    println(list[K-1])
}