require 'prime'

def gcd(a, b)
  x = a % b
  if x == 0
    b
  else
    gcd(b, x)
  end
end

n, m, k = gets.split(' ').map(&:to_i)

a = gcd(n, m)

if k == 1
  puts a
else
  divs = Prime.prime_division(a).map{|n, e|
	  (0..e).map{|i| n ** i }
    }.inject([1]){ |a, b|
      a.product(b).map{|ai, bj| ai * bj }
    }.sort
  puts divs[-k]
end