require 'prime'

def ore a,b
  c = Rational(a,b).denominator
  c.prime_division.each do |s|
    return false unless [2,5].include? s[0]
  end
  return true
end

a,b,k = gets.chomp.split().map(&:to_i)
max=[a,b].max
(1..max).each do |n|
  if ore(a,n) && ore(b,n)
     k-=1
    if k==0
      puts n
      break
    end
  end
end