object Main extends App {

  val Array(a,b,k) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

  def solve(): Int = {
    (Math.min(a, b) to 1 by -1).filter { i =>
      a % i == 0 && b % i == 0
    }(k-1)
  }



  println(solve)

}
