'use strict';
console.log(function(args){
  const _tmp = args.trim().split(' ');
  const A = _tmp[0]|0, B = _tmp[1]|0;
  let K = _tmp[2]|0;
  const divisor = [];
  for ( let i = A; i >= 1; i-- ) {
    if ( A%i === 0 ) divisor.push(i);
  }
  for ( let j of divisor ) {
    if ( B%j === 0 && --K === 0 ) return j.toString();
  }
  return '1';
}(require('fs').readFileSync('/dev/stdin', 'utf8')));