function main(input) {
  const args = input.split(' ').map(n => parseInt(n, 10));
  const A = args[0],
        B = args[1],
        K = args[2];
  let cnt = 0;
  
  for (let i = 100; i >= 1; i--) {
    if (A % i === 0 && B % i === 0) {
      cnt++;
      if (cnt === K) {
        console.log(i);
        break;
      }
    }
  }
}

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