import Foundation

extension String {
    func split(separator: String) -> [Int] {
        return self.componentsSeparatedByString(separator).map { Int($0)! }
    }
}

let input = readLine()!.split(" ")
let A = input[0]
let B = input[1]
let K = input[2]

var divisor: [Int] = []
for i in 1...100 {
    if (A % i == 0) && (B % i == 0) {
        divisor.append(i)
    }
    if divisor.count > K {
        break
    }
}

print(divisor[K-1])