function main(input) {
  var inputList = input.split(" ");
  var a = Number(inputList[0]);
  var b = Number(inputList[1]);
  var k = Number(inputList[2]);
  var max = a >= b ? a: b;

  var arr = [];
  for(i=1; i<=max; i++){
    if(a % i===0 && b % i===0){
      arr.push(i);
    }
  }

  var rev = arr.reverse();
  console.log(rev[k-1]);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));
