import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()
  val k = sc.nextInt()


  val min = Math.min(a, b)
  val list = mutableListOf<Int>()
  for (i in 1..min) {
    if (a % i == 0 && b % i == 0) {
      list.add(i)
    }
  }

  list.reverse()
  println(list.get(k-1))

}
