import io.StdIn._

object Main extends App {
  val Seq(a, b, k) = readLine().split(" ").map(_.toInt).toSeq

  require(1 <= a && a <= 100)
  require(1 <= b && b <= 100)
  require(k >= 1)

  println((1 to 100).filter(i => (a % i == 0 && b % i == 0)).reverse.take(k).last)
}
