function main(input) {
  var a = input.split(" ")[0]-0, b = input.split(" ")[1]-0, c = input.split(" ")[2]-0;
  var base = Math.min(a,b);
  for(var i=base;i>=1;i--){
    if(a%i==0 && b%i==0) c--;
    if(c==0) {console.log(i); return}
  }
}

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