object Main extends App {
  var get = readLine
  var a = get.split(" ")(0).toInt
  var b = get.split(" ")(1).toInt
  var c = get.split(" ")(2).toInt
  var sum = 0
  var loop = 1
  var K = 0
  while(loop <= a && loop <= b) {
    if(a % loop == 0 && b % loop == 0){
      sum += 1
      if( sum == c)
	      K = loop
    }
    loop += 1
  }
  println(K)
}