a, b, k= gets.chomp.split(' ').map(&:to_i)

answer=[]
(1..100).each do |n|
  if a%n ==0 && b%n ==0
    answer << n
  end
end

# answer => [1,2,4]
answer.reverse
# answer =>[4, 2, 1]
# indexは0スタートなので -1する
puts answer[k -1]