import java.util.*

fun gcd(x: Int, y: Int): Int {
    var a = x
    var b = y
    if (b > a) {
        a = y
        b = x
    }
    var c = a % b
    while (c != 0) {
        a = b
        b = c
        c = a % b
    }
    return b
}

fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val a = cin.nextInt()
    val b = cin.nextInt()
    val k = cin.nextInt()
    
    var count = 0

    for (i in 0..99) {
        val j = 100 - i
        if (a % j == 0 && b % j == 0) {
            count += 1
        }
        if (count == k) {
            println(j)
            return
        }
    }
}