function Main(input) {
    input = input.split(" ");
    A = Number(input[0]);
    B = Number(input[1]);
    K = Number(input[2]);
    P = [];
    for(i = 1; i <= Math.min(A,B); i++){
        if(A % i === 0 && B % i === 0) P.unshift(i);
    }
    console.log(P[K-1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));