fun main(args: Array<String>) {
    val arr = readLine()!!.split(" ").map { s->s.toInt() }
    val g = gcd(arr[0],arr[1])
    var c =0
    for (i in 1..g){
        if(g%i==0){
            c+=1
            if(c==arr[2]){
                print( g/i)
            }
        }
    }
}

fun gcd(a:Int,b:Int):Int{
    return if (a>b) gcd(b,a) else if(a>0)gcd(b%a,a) else b
}