def r;gets.split.map &:to_i;end
def rr(n);n.times{yield r};end

A,B,K = r

count = 0
1.upto(100) do |i|
  if A % i == 0 && B % i == 0
    count += 1
    if count == K
      puts i
      exit
    end
  end
end
