A,B,K = gets.split.map(&:to_i)
Aarray = Array.new
Barray = Array.new

for i in 1..A
 if A%i == 0
  Aarray.push(i)
 end
end

for i in 1..B
 if B%i == 0
  Barray.push(i)
 end
end

Carray = Array.new
for x in 0..(Aarray.length-1)
 for y in 0..(Barray.length-1)
  if Aarray[x] == Barray[y]
   Carray.push(Aarray[x])
  end
 end
end

puts(Carray[Carray.length-K])