#!/bin/ruby

a, b, k = gets.chomp.split(" ").map(&:to_i)

divide = 1
cnt = 0
dividable_numbers = []
while true
  if a % divide == 0 && b % divide == 0
    dividable_numbers << divide
    cnt += 1
    divide += 1
  else
    divide += 1
  end
  break if divide > a || divide > b
end
puts dividable_numbers[-k]
