A,B,K=map(int,input().split())
count=0
for i in reversed(range(min(A,B))):
  if A%(i+1)==0 and B%(i+1)==0:
    count+=1
  if count==K:
    print(i+1)
    break A,B,K=map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B K count=0 count 0 for i in reversed(range(min(A,B))):
  if A%(i+1)==0 and B%(i+1)==0:
    count+=1
  if count==K:
    print(i+1)
    break i reversed(range(min(A,B))) reversed range(min(A,B)) range min(A,B) min A B if A%(i+1)==0 and B%(i+1)==0:
    count+=1
   A%(i+1)==0 and B%(i+1)==0 A%(i+1)==0 A%(i+1) A i+1 i 1 0 B%(i+1)==0 B%(i+1) B i+1 i 1 0 count+=1 count 1 if count==K:
    print(i+1)
    break count==K count K print(i+1) print i+1 i 1 break A,B,K=map(int,input().split()) map(int,input().split()) A K=map(int,input().split()) map(int,input().split()) K count+=1 1 count B,K=map(int,input().split()) map(int,input().split()) B count=0 0 count
A,B,K=map(int,input().split())
count=0
for i in reversed(range(min(A,B))):
  if A%(i+1)==0 and B%(i+1)==0:
    count+=1
  if count==K:
    print(i+1)
    break