void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1], k = tmp[2];
    int[] divisor;
    foreach (i; 1 .. min(a, b)+1) {
        if (a % i == 0 && b % i == 0) {
            divisor ~= i;
        }
    }
    divisor.sort!"a > b";
    divisor[k-1].writeln;
}

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