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