import io.StdIn._
 
object Main extends App {
  val Seq(a, b, k): Seq[Int] = readLine().split(" ").map(_.toInt)
 
  var x = 1
  var y = 0
  var z = 0
  while(y < k) { 
   	if(a%x==0 && b%x==0){
      y += 1
      z = x
    }
    x += 1
  }
  println(z)
}