# frozen_string_literal: true

a, b, k = gets.split.map(&:to_i)
count = 0
100.downto(1) do |i|
#  puts "#{i} #{a % i.to_f} #{b % i.to_f}"
  count += 1 if a % i == 0 && b % i == 0
  if count == k
    puts i
    exit
  end
end
