inputs = STDIN.gets.chomp.split(' ').map(&:to_i)

# inputs => [A, B, K]

def factor(num)
  f = []
  i = 1
  while i <= num do
    if num % i == 0
      f << i
    end
    i += 1
  end
  f
end

div_a = factor inputs[0]
div_b = factor inputs[1]
div_common = div_a & div_b
div_common.reverse

puts div_common.reverse[inputs[2]-1]
