object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toInt).toIndexedSeq).head
  val A = ls(0)
  val B = ls(1)
  val K = ls(2)
  var count = 0
  var i=Math.min(A,B)
  while(count<K){
    if(A%i==0 && B%i==0) count+=1
    i-=1
  }
  val ret = i+1
  println(ret)
}
