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

void main() {
    int a, b, k; readf("%d %d %d\n", &a,&b,&k);
    iota(1, 100).filter!(i => a%i == 0 && b%i == 0)
        .array
        .reverse[k - 1]
        .writeln;
}