def resolve():
    A, B, K = list(map(int, input().split()))
    cnt = 0
    i = max(A, B)
    while True:
        if A%i==0 and B%i==0:
            cnt += 1
            if cnt == K:
                break
        i -= 1
    print(i)

if '__main__' == __name__:
    resolve() def resolve():
    A, B, K = list(map(int, input().split()))
    cnt = 0
    i = max(A, B)
    while True:
        if A%i==0 and B%i==0:
            cnt += 1
            if cnt == K:
                break
        i -= 1
    print(i) resolve A, B, K = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split B K cnt = 0 cnt 0 i = max(A, B) i max(A, B) max A B while True:
        if A%i==0 and B%i==0:
            cnt += 1
            if cnt == K:
                break
        i -= 1
     True if A%i==0 and B%i==0:
            cnt += 1
            if cnt == K:
                break
         A%i==0 and B%i==0 A%i==0 A%i A i 0 B%i==0 B%i B i 0 cnt += 1 cnt 1 if cnt == K:
                break
         cnt == K cnt K break i -= 1 i 1 print(i) print i if '__main__' == __name__:
    resolve() '__main__' == __name__ '__main__' __name__ resolve() resolve def resolve():
    A, B, K = list(map(int, input().split()))
    cnt = 0
    i = max(A, B)
    while True:
        if A%i==0 and B%i==0:
            cnt += 1
            if cnt == K:
                break
        i -= 1
    print(i) def resolve():
    A, B, K = list(map(int, input().split()))
    cnt = 0
    i = max(A, B)
    while True:
        if A%i==0 and B%i==0:
            cnt += 1
            if cnt == K:
                break
        i -= 1
    print(i) resolve
def resolve():
    A, B, K = list(map(int, input().split()))
    cnt = 0
    i = max(A, B)
    while True:
        if A%i==0 and B%i==0:
            cnt += 1
            if cnt == K:
                break
        i -= 1
    print(i)

if '__main__' == __name__:
    resolve()