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 = divisorA.filter(function(element){return divisorB.includes(element);})
    
    console.log(divisorAB[divisorAB.length-(order)])
}

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