import java.util.Scanner
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val a = sc.nextInt()
    val b = sc.nextInt()
    var k = sc.nextInt()

    for(i in 100 downTo 1){
        if(a%i==0&&b%i==0) k--
        if(k==0) {
            println(i)
            return
        }
    }
}