const main = stdin => {
  const input = stdin.trim().split('\n')

  const [A, B, K] = input[0].split(' ').map(x => parseInt(x))
  const answers = []
  for (let i = 1; i <= Math.min(A, B); i++) {
    if (A % i === 0 && B % i === 0) {
      answers.push(i)
    }
  }

  console.log(answers[answers.length - K])
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))
