function main(lines) {
    const input = lines.split(' ').map(Number)
    const A = input[0]
    const B = input[1]
    const order = input[2]
    
    var divisorA = []
    var divisorB = []
    for(var i=1; i<=A; i++){
        if(A%i === 0){
            divisorA.push(i)
        }
    }
        
    for(var i=1; i<=B; i++){
        if(B%i === 0){
            divisorB.push(i)
        }
    }
 

    var divisorAB = []
    for(var i=0; i<Math.max(divisorA.length,divisorB.length); i++){
      for(var k=0; k<Math.max(divisorA.length,divisorB.length); k++){
        if( divisorA[i] === divisorB[k]){
          divisorAB.push(divisorA[i])
          break;
        }
      }
    }
    
    console.log(divisorAB[divisorAB.length-(order)])
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));