import io.StdIn._

object Main extends App {
  val Seq(a, b, k) = readLine().split(" ").map(_.toInt).toSeq

  require(1 <= a && a <= 100)
  require(1 <= b && b <= 100)
  require(k >= 1)

  var i = 0
  var j = 0
  while (j != k) {
    i = i + 1
    if (a % i == 0 && b % i == 0) j = j + 1
  }

  println(i)
}
