// Atcoder120 - B
function divisor(n) {var ret=[]; for (var i=1;i*i<=n;i++){if(n%i==0){ret.push(i);if(i*i!=n)ret.push(n/i);}}return ret;}
function main(input) {
  var inputs = input.split('\n');
  var abks = inputs[0].split(' ');
  var a = abks[0];
  var b = abks[1];
  var k = abks[2];

  var aDivisors = divisor(a);
  var bDivisors = divisor(b);

  var counter = 0;
  var kthCd = 0;
  console.log(aDivisors.sort((i, j) => i - j));
  aDivisors.sort((i, j) => i - j).some((item) => {
    counter += bDivisors.indexOf(item) >= 0 ? 1 : 0;
    if (counter == k) {
      kthCd = item;
      return true;
    }
  });

  console.log(kthCd);
}

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