fun main(args: Array<String>) = yorukatsu14a()

fun yorukatsu14a() {
    val (a, b, k) = readLine()!!.split(' ').map { it.toInt() }

    val div = mutableListOf<Int>()

    for (i in 1..Math.max(a, b)) {
        if (a % i == 0 && b % i == 0) div.add(i)
    }

    val answer = div[div.lastIndex - k + 1]

    println(answer)
}
