def factor(num)
  result = [1]
  i = 2
  while i<=num do
    if num%i==0
      result << i
    end
    i += 1
  end
  result
end

a,b,x = gets.split(" ").map{|e| e.to_i}
ab = [a,b].sort
fa = factor(ab[0])
fb = factor(ab[1])
f = fb & fa
puts f[-x]