import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  var (_a, _b, k) = (sc.nextInt(), sc.nextInt(), sc.nextInt())
  val a = math.max(_a, _b)
  val b = math.min(_a, _b)

  (1 to b).reverse.foreach { i =>
    if (a % i == 0 && b % i == 0) {
      k -= 1
      if (k == 0) {
        println(i)
        sys.exit()
      }
    }
  }
}