a, b, k = gets.split.map(&:to_i)
d = a.gcd(b)
sqrt_d = Math.sqrt(d).to_i

small_divs = []
(1..sqrt_d).each{|n|
    next if d % n != 0
    if k == 1
        puts d / n
        exit
    else
        k -= 1
    end
    if !(n == sqrt_d && sqrt_d == Math.sqrt(d))
        small_divs.push(n)
    end
}
puts small_divs.reverse()[k - 1]
