object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val A,B,K = sc.nextInt
  val isOK:(Int) => Boolean =(N)=>{
    A%N + B%N == 0
  }
  val OKlist = (100 until 0).filter(isOK)
  val OKList2 = List.tabulate(100){x:Int=>x+1}.filter(isOK)
  val ans = OKList2(OKList2.size-K)
  println(ans)
}
