def resolve():
    A, B, K = list(map(int, input().split()))
    mx = min(A, B)
    ans = []
    for i in range(1, mx+1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
    print(ans[-K])
    return

resolve() def resolve():
    A, B, K = list(map(int, input().split()))
    mx = min(A, B)
    ans = []
    for i in range(1, mx+1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
    print(ans[-K])
    return 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 mx = min(A, B) mx min(A, B) min A B ans = [] ans [] for i in range(1, mx+1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
     i range(1, mx+1) range 1 mx+1 mx 1 if A % i == 0 and B % i == 0:
            ans.append(i)
     A % i == 0 and B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 ans.append(i) ans.append ans append i print(ans[-K]) print ans[-K] ans -K K return resolve() resolve def resolve():
    A, B, K = list(map(int, input().split()))
    mx = min(A, B)
    ans = []
    for i in range(1, mx+1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
    print(ans[-K])
    return def resolve():
    A, B, K = list(map(int, input().split()))
    mx = min(A, B)
    ans = []
    for i in range(1, mx+1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
    print(ans[-K])
    return resolve
def resolve():
    A, B, K = list(map(int, input().split()))
    mx = min(A, B)
    ans = []
    for i in range(1, mx+1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
    print(ans[-K])
    return

resolve()