function main(input) {
  const A = parseInt(input.split(" ")[0] , 10);
  const B = parseInt(input.split(" ")[1] , 10);
  const K = parseInt(input.split(" ")[2] , 10);
  var chibi=Math.min.apply(null, [A,B]);
  var arr=[];
  for(var i=1; i<=chibi; i++){
    if(A%i==0&&B%i==0){
      arr.push(i)
    }
  }
  console.log(arr[arr.length-K]);
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));