# frozen_string_literal: true
d = []
def chmin(a, b)
  a > b ? b : a
end
a, b, k = gets.split.map(&:to_i)

c = a

cnt = 0
i = 1
ans = 0
while c
    if a < i || b < i
        break
    end
  if a % i == 0 && b % i == 0
    d << i
  end
  i += 1
end

puts d[d.length - k]
