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

ans = 0

t = [A, B].min
# p t
k = 0

t.downto(1) do |i|
  
  k+=1 if ( A % i == 0 && B % i == 0)
  # p [i,k] if ( A % i == 0 && B % i == 0)
  if k == K
    ans = i
    break
  end
  
end

# puts [t,k]
puts ans