function Main(input) {
  input = input.split(" ");
  var a = input[0];
  var b = input[1];
  var k = input[2];
  var ary = new Array();
  for(var i = 1; i < 101; i++ ) {
    if( a%i === 0 && b%i === 0 ) {
      ary.push(i);
      if(ary.length == k) {
        console.log(ary[k - 1]);
        return false;
      }
    }
  }
  console.log(ary[k - 1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));