const makeCommonMultiple = x => {
    let ar = []
    for (let i = 0; i <= x; i++) {
        if (!(x % i)) {
            ar.push(i)
        }
    }
    return ar
}

function main(input) {
    let num1, num2, kth;

    [num1, num2, kth] = input.split(' ').map((x) => x - [])

    const [ar1, ar2] = [makeCommonMultiple(num1),makeCommonMultiple(num2)]


    const unUniq = ar1.filter(x => ar2.indexOf(x) != -1)

    kth = (unUniq.length) - kth

    console.log(unUniq[kth])

}

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