local function getgcd(x, y)
  while(0 < x and 0 < y) do
    if(x < y) then y = y % x else x = x % y end
  end
  return math.max(x, y)
end

local a, b, k = io.read("*n", "*n", "*n")
local c = getgcd(a, b)
local cnt = 1
for i = c, 1, -1 do
  if(c % i == 0) then
    if(cnt == k) then print(i) break
    else cnt = cnt + 1 end
  end
end
