a,b,k = gets.strip.split(" ").map(&:to_i)

A = []
B = []
i = 1
while true
  A.push(i) if a % i == 0
  i += 1
  break if a < i
end
i = 1
while true
  B.push(i) if b % i == 0
  i += 1
  break if b < i
end
C = A & B
puts C[k-1]