a,b,c=gets.split(" ").map(&:to_i)
require 'prime'
k = a.gcd(b)
d = [1]
p = []
Prime.prime_division(k).each do |pr|
  pr[1].times {p << pr[0]}
end

1.upto(p.size) do |i|
  p.combination(i) do |prime|
    d << prime.inject{|ka,kb| ka *= kb}
  end
end

p d.uniq.sort.reverse[c-1]