process.stdin.resume();
process.stdin.setEncoding('utf8');

let lines = [];

let reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

reader.on('line', (line) => {
    lines.push(line);
});

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

reader.on('close', () => {
    let num1, num2, kth;

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

    let ar1, ar2;

    ar1 = makeCommonMultiple(num1)
    ar2 = makeCommonMultiple(num2)

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

    kth = (unUniq.length) - kth

    console.log(unUniq[kth])

});