A, B, K = map(int,input().split())

C = min(A, B)

cnt = 0

while(1):
    if(A % C == 0 and B % C == 0):
        cnt+=1
    if(cnt == K):
        print(C)
        exit()
    C -= 1 A, B, K = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B K C = min(A, B) C min(A, B) min A B cnt = 0 cnt 0 while(1):
    if(A % C == 0 and B % C == 0):
        cnt+=1
    if(cnt == K):
        print(C)
        exit()
    C -= 1 1 if(A % C == 0 and B % C == 0):
        cnt+=1
     A % C == 0 and B % C == 0 A % C == 0 A % C A C 0 B % C == 0 B % C B C 0 cnt+=1 cnt 1 if(cnt == K):
        print(C)
        exit()
     cnt == K cnt K print(C) print C exit() exit C -= 1 C 1 K = map(int,input().split()) map(int,input().split()) K A, B, K = map(int,input().split()) map(int,input().split()) A cnt = 0 0 cnt cnt+=1 1 cnt B, K = map(int,input().split()) map(int,input().split()) B C = min(A, B) min(A, B) C C -= 1 1 C
A, B, K = map(int,input().split())

C = min(A, B)

cnt = 0

while(1):
    if(A % C == 0 and B % C == 0):
        cnt+=1
    if(cnt == K):
        print(C)
        exit()
    C -= 1
