object Main extends App {
	val Array(a, b, k) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
 	var ans = List[Int]()

 	for(i<-1 to math.min(a,b)){
 		if(a%i == 0 && b%i == 0){
 			ans ::= i
 		}
 	}

 	println(ans(k-1))
}