function Main(input) {
  input = input.split("\n");
  var a = parseInt(input[0], 10);
  var b = parseInt(input[1], 10);
  var c = parseInt(input[2], 10);
  var arr = [];
  for(var i = Math.max(a, b); i >= 1;  i--) {
    if(a % i === 0 && b % i === 0) {
      arr.push(i);
    }
  }
  console.log(arr[c-1]);
}

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