import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
 
void main()
{
    int A, B, r, K;
    auto input = readln.split.to!(int[]);
    A = input[0];
    B = input[1];
    K = input[2];
    while(A%B)
    {
        r = A%B;
        A = B;
        B = r;
    }
  	int[] ans = new int[100];
  	ans[0] = B;
  	int j = 1;
  	for(int i = 2; i <= B; i++) {
    	if(B%i == 0)
        {
          	ans[j] = B / i;
          	j++;
        }
    }
  	writeln(ans[K-1]);
}