import std.stdio, std.conv, std.string, std.random, std.range, std.typecons, std.math;
import std.algorithm.comparison, std.algorithm.iteration;
import std.algorithm.mutation, std.algorithm.searching, std.algorithm.sorting;

void main()
{
    auto input = readln().strip.split.to!(int[]);
    auto A = input[0];
    auto B = input[1];
    auto K = input[2];
    int count;
    foreach_reverse(i; 0..101)
    {
        count += A%i == 0 && B%i==0 ? 1 : 0;
        if(count==K)
        {
            writeln(i);
            return;
        }
    }
}
