"use strict";
const main = input => {
    const a = Number(input[0].split(' ')[0]);
    const b = Number(input[0].split(' ')[1]);
    const k = Number(input[0].split(' ')[2]);
    let count=0;
    for(let i=Math.max(a,b); i>=0; i--) {
        if (a%i==0 && b%i==0) {
            count++
            if (count == k) {
                console.log(i);
                return;
            }
        }
    }
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));