import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit = {
    val a = sc.nextInt
    val b = sc.nextInt
    val k = sc.nextInt

    val d = gcd(a,b)
    val r = (d to 1 by -1).filter(d % _ == 0)(k - 1)

    println(r)
  }

  def gcd(a: Int , b: Int): Int ={
    if(b == 0) a
    else
    if(a < b) gcd(b,a)
    else gcd(a % b,b)
  }

}