object Main {
  def main(args: Array[String]): Unit = {
    val Seq(a, b, k) = io.StdIn.readLine().split(" ").map(_.toInt).toSeq

    val m = math.min(a, b)

    println {
      (m to 1 by -1).toStream
        .filter(x => a % x == 0 && b % x == 0)(k - 1)
    }
  }
}
