ar = gets.chomp.split(" ").map{|i|i = i.to_i}
a=ar[0]
b=ar[1]
k=ar[2]
def gcd(a,b)
    while b>0 do
        a,b = b,a%b
    end
    return a
end
ar = []
gcd=gcd(a,b)
gcd.times do|i|
    if gcd % (i+1)==0 then
        ar<<(i+1)
    end  
end
ar.uniq!
ar.sort!
pp ar[ar.length-k]