import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const tmp = readln.split.to!(long[]);
    const A = tmp[0], B = tmp[1], K = tmp[2];

    int cnt;
    foreach_reverse (x; 1..min(A,B)+1) {
        if (A % x == 0 && B % x == 0) {
            if (++cnt == K) {
                writeln(x);
            }
        }
    }
}

