object Main extends App {
  val in = io.StdIn.readLine.split(' ').map(_.toInt)

  val A = in(0)
  val B = in(1)
  val K = in(2)

  val out = (math.min(A,B) to 1 by -1).filter(i => A % i == 0 && B % i ==0)

  println(out(K-1))
}
