A, B, K = gets.split.map(&:to_i)

if K == 1
  puts 1
  exit
end

ans = 0
([A, B].min).downto(1) do |n|
  if A%n == 0 and B%n == 0
    ans += 1
    if ans == K
      puts n
      exit
    end
  end
end