"""
全探索
1からmin(a,b)の中でaとbを割り切るものの数をカウントする
"""
a, b, k = map(int, input().split())
counter = 0
for i in list(range(1,min(a,b)+1))[::-1] :
    if a%i == 0 and b%i == 0 :
        counter += 1
    if counter == k :
        print(i)
        break """
全探索
1からmin(a,b)の中でaとbを割り切るものの数をカウントする
""" a, b, k = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b k counter = 0 counter 0 for i in list(range(1,min(a,b)+1))[::-1] :
    if a%i == 0 and b%i == 0 :
        counter += 1
    if counter == k :
        print(i)
        break i list(range(1,min(a,b)+1))[::-1] (range(1,min(a,b)+1)) list range(1,min(a,b)+1) range 1 min(a,b)+1 min(a,b) min a b 1 ::-1 -1 if a%i == 0 and b%i == 0 :
        counter += 1
     a%i == 0 and b%i == 0 a%i == 0 a%i a i 0 b%i == 0 b%i b i 0 counter += 1 counter 1 if counter == k :
        print(i)
        break counter == k counter k print(i) print i break b, k = map(int, input().split()) map(int, input().split()) b counter = 0 0 counter a, b, k = map(int, input().split()) map(int, input().split()) a k = map(int, input().split()) map(int, input().split()) k counter += 1 1 counter
"""
全探索
1からmin(a,b)の中でaとbを割り切るものの数をカウントする
"""
a, b, k = map(int, input().split())
counter = 0
for i in list(range(1,min(a,b)+1))[::-1] :
    if a%i == 0 and b%i == 0 :
        counter += 1
    if counter == k :
        print(i)
        break
