"use strict";

const main = arg => {
    const A = parseInt(arg.split("\n")[0].split(" ")[0]);
    const B = parseInt(arg.split("\n")[0].split(" ")[1]);
    const K = parseInt(arg.split("\n")[0].split(" ")[2]);
    const list = [];
    
    for(let i=1; i<=Math.min(A,B); i++) {
        if(A % i == 0 && B % i == 0) {
            list.push(i);
        }
    }
    
    console.log(list[list.length - K]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));