line = gets.chomp.split.map(&:to_i)
a = line[0]
b = line[1]
k = line[2]

times = 0
ans = 0
i = b
while i > 1 do
    if a % i == 0 and b % i == 0
        times += 1
        ans = i
    end
    break if times == k
    i -= 1
end

puts ans
