import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val A = sc.nextInt
    val B = sc.nextInt
    val K = sc.nextInt

    val a = new ArrayBuffer[Int]()
    var i = 0
    for (i <- 100 to 1 by -1) {
      if (A % i == 0 && B % i == 0) {
        a.append(i)
      }
    }
    a(K - 1).toString
  }
}
