import java.util.Scanner

fun main(args: Array<String>) {
  val scanner = Scanner(System.`in`)
  val A = scanner.nextInt()
  val B = scanner.nextInt()
  var K = scanner.nextInt()
  scanner.close()
  for (i in 100 downTo 1) {
    if (A % i == 0 && B % i == 0) {
      K--
      if (K == 0) {
        print(i)
        return
      }
    }
  }
}