object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b, k = sc.nextInt
  val ans = (1 to math.min(a, b))
    .map(math.min(a,b) - _ + 1)
    .filter{ i =>
      a % i == 0 && b % i == 0
    }(k - 1)

  println(ans)

}