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
  # print m1, " % ", n1, " = ", r
  # puts ""
  while r > 0
    m1 = n1
    n1 = r
    r = m1 % n1
    # print m1, " % ", n1, " = ", r
    # puts ""
  end
  return n1
end

c = gcd(a,b)

count = 1

while count < k do
  c -= 1
  if a % c == 0 and b % c == 0
    count += 1
  end
end

print c