function main(input) {
  const args = input.split(' ');
  let A = Number(args[0]);
  let B = Number(args[1]);
  let K = Number(args[2]);
  let cu = 0;
  let sum;
  let count = 0;
  for (cu = A; cu > 0; --cu) {
    if (Number.isInteger(A / cu) && Number.isInteger(B / cu)) {
      count++;
      if (count === K) {
        sum = cu;
        break;
      }
    }
  }
  console.log(sum);
}