line = gets
line.chomp!

/(\d+)\s*(\d+)\s*(\d+)/ =~ line
a = $1.to_i
b = $2.to_i
k = $3.to_i

if a < b then
  c = a
  a = b
  b = c
end

# 最大公約数
def gcd (m,n)
  r = m % n
  m1 = m
  n1 = n
  while r > 0
    m1 = n1
    n1 = r
    r = m1 % n1
  end
  return n1
end

c = gcd(a,b)

# 約数列挙
def divisors (n)
  array = []
  max = Math.sqrt(n).to_i
  for num in 1..max do
    if n%num == 0
      array.push(num)
      pair = n/num
      if (pair != num)
        array.push(pair)
      end
    end
  end
  return array.sort
end

print divisors(c)[-k]
