"use strict"
function Main(input){
  input=input.trim();
  input=input.split(/\s+/);
  for(let i=0;i<input.length;i++)
    input[i]=input[i]-0;
  var A=input[0];
  var B=input[1];
  var K=input[2];
  var num=Math.min(A,B);
  var counter=0;
  while(counter<K){
    counter+=(A%num===0&&B%num===0)?1:0;
    num--;
  }
  console.log(num+1);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));