require "prime"
a, b, k = gets.split(" ").map(&:to_i)

def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

a_dev = divisors(a)
b_dev = divisors(b)

ab_dev = a_dev & b_dev

puts ab_dev[-k]