def gcd(a,b)
    while b>0 do
        a,b = b,a%b
    end
    return a
end


ar = gets.chomp.split(" ").map{|i|i = i.to_i}
a=ar[0]
b=ar[1]
k=ar[2]

arr = []

s=gcd(a,b)
s.times do|i|
    if s % (i+1)==0 then
        arr << (i+1)
    end
end
l = arr.length
pp arr[(l-k)]