object Main{
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val List(a,b,k) = List.fill(3)(sc.nextInt)
    val gcdAB = gcd(a,b)
    var divisor = 1
    var ans:Int = gcdAB
    var count = 0
    while(count != k){
      if(gcdAB % divisor == 0){
        count += 1
        ans = gcdAB / divisor
      }
      divisor += 1
    }
    
    println(ans)
    
  }
  
  def gcd(a:Int, b:Int) : Int = {
    if(a<b) gcd(b,a) else if(b==0) a else gcd(b,a%b)
  }
}