function Main(input) {
  input = input.split("\n")[0].split(" ");
  var a = parseInt(input[0]);
  var b = parseInt(input[1]);
  var c = parseInt(input[2]);
  var arr = [];
  for(var i = parseInt(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"));