function Main(input){
	var temp = input.split(" ");
	var A = parseInt(temp[0]);
	var B = parseInt(temp[1]);
	var K = parseInt(temp[2]);

	var min = Math.min(A,B);
	var count = 0;
	for(var i=min;i>=1;i--){
		if(A%i===0 && B%i===0){
			count++;
		}
		if(count === K){
			console.log(i);
			break;
		}
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));