function Main(input) {

    input = input.split(" ");

    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);
    var k = parseInt(input[2], 10);

    var count = 0;
    var value = 0;

    for (var i = 100; i > -1; i--) {

        if ((a % i == 0) && (b % i == 0)) {
            count++;
        }

        if (count == k) {
            value = i;
            break;
        }

    }




    console.log(value);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
