object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val A = sc.nextInt
  val B = sc.nextInt
  val K = sc.nextInt
  val result = (List(A, B).min to 1 by -1).filter(x => A % x == 0 && B % x == 0)(K - 1)
  println(result)
}