// @ts-ignore
require("fs").readFile("/dev/stdin", "utf8", (err, input) => {
  const [a, b, k] = input.split(" ")
  const m = Math.max(a, b)
  const r = [...Array(m).keys()]
    .map((_, i) => {
      return i
    })
    .filter((i) => {
      return a % i == 0 && b % i == 0
    })
  console.log(r[parseInt(k)])
})
