A, B, C = $stdin.read.chomp.split(" ").map(&:to_i)

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

def divs(n)
  res = []
  i = 1
  while i * i <= n do

    if n % i == 0
      res << i
      if i != 0 && i * i != n
        res << n / i
      end
    end
    i += 1
  end
  res
end

a = A > B ? A : B
b = A > B ? B : A

g = gcd(a, b)
ds = divs(g).sort_by{|x| -1 * x}

puts ds[C-1]

