

object Main {

  val amari = 1000000007

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val A, B, K = sc.nextInt()
    var x = 0
    var i = Math.max(A, B) + 1
    while (x != K) {
      i = i - 1
      if (A % i == 0 && B % i == 0) {
        x = x + 1
      }
    }
    println(i)
  }
}
