input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
a = line[0] * 1
b = line[1] * 1 
k = line[2] * 1

_dividers = function(n) {
  var arr = []
  for (var i = 1; i*i <= n; i++) {
     if (n % i === 0) {
       arr.push(i)
       if ( i != n / i) {
         arr.push(n / i)
       }
     }
  }
  return arr.sort((a, b) => b - a)
}

a_d = _dividers(a)
b_d = _dividers(b)

arr = []
c = a_d.filter((x) => b_d.indexOf(x) >= 0)

console.log(c[k-1])