a, b, k = gets.chomp.split.map(&:to_i)
c = [a, b]
d = c.min
result = 0
for x in 1..d
  y = d + 1 - x
  if a % y == 0
    if b % y == 0
      result = result + 1
      if result == k
        puts y
        exit
      end
    end
  end
end
