a, b, k = gets.chomp.split(' ').map(&:to_i)
  
def gcd(a, b)
  if (a > b)
    return gcd(a-b, b) 
  elsif (a < b)
    return gcd(a, b-a)
  else
    return a
  end
end

n = gcd(a, b)
j = 0

n.downto(1) do |i|
  if (n % i == 0)
    j+=1
  end
  if (j == k)
    puts i
    break
  end
end