fun main(args: Array<String>) {
    var (a,b,k) = readLine()!!.split(" ").map(String::toInt)
    var list:MutableList<Int> = mutableListOf()
    var c= 1
    while(a>=c || b>=c){
        if(a%c==0 && b%c == 0) list.add(c)
        c++
    }
    
    println(list[list.size - k])
}
