'use strict';

function Main(input) {
  const A = Number(input.split(" ")[0])
  const B = Number(input.split(" ")[1])
  const K = Number(input.split(" ")[2])
  let counter = 0

  for (let i = Math.max(A, B); i > 0; i--) {
      if (A % i === 0 && B % i === 0) {
          counter++
      }
      if (counter === K) {
          console.log(i)
          return
      }
  }
  
};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
