object Main extends App {

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

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



  println(solve)

}