import scala.io.StdIn.readLine

object Main extends App {
  val Array(a, b, k) = readLine().split(' ').map(_.toInt)
  
  val aDivisors = (1 to a).filter(x => a % x == 0).toSet
  val bDivisors = (1 to b).filter(x => b % x == 0).toSet
  val commonDivisors = aDivisors.intersect(bDivisors).toSeq.sorted.reverse
  println(commonDivisors(k - 1))
}