# https://atcoder.jp/contests/abc120/tasks/abc120_b
# B - K-th Common Divisor

A, B, K = gets.chomp.split().map(&:to_i)


num = [A,B].min()
i = num

nums = []

while i != 0
    nums << i if (A % i) == 0 and (B % i) == 0   
    i = i - 1 
end

p nums[K-1]