fun main(args : Array<String>) {
    val (a, b, k) = readLine()!!.split(" ").map { it.toInt() }
    val min = Math.min(a, b)

    val ans = mutableListOf<Int>()

    for (i in 1..min) {
        if (a % i == 0 && b % i == 0) ans.add(i)
    }

    println(ans.sortedDescending()[k-1])
}
