def read_i
  gets.chomp.split(' ').map(&:to_i)
end

a,b,k = read_i

num = a < b ? a : b
divisor = []

num.times do |i|
  n = i + 1
  if (a % n == 0) && (b % n == 0)
    divisor << n
  end
end
puts divisor[-k]