import math

a,b,k=map(int,input().split())
cnt=0

for i in range(math.gcd(a,b),0,-1):
    if a%i==0 and b%i==0:
        cnt+=1
    
    if cnt==k:
        print(i)
        break import math math a,b,k=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b k cnt=0 cnt 0 for i in range(math.gcd(a,b),0,-1):
    if a%i==0 and b%i==0:
        cnt+=1
    
    if cnt==k:
        print(i)
        break i range(math.gcd(a,b),0,-1) range math.gcd(a,b) math.gcd math gcd a b 0 -1 if a%i==0 and b%i==0:
        cnt+=1
    
     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:
        print(i)
        break cnt==k cnt k print(i) print i break b,k=map(int,input().split()) map(int,input().split()) b cnt=0 0 cnt cnt+=1 1 cnt k=map(int,input().split()) map(int,input().split()) k a,b,k=map(int,input().split()) map(int,input().split()) a
import math

a,b,k=map(int,input().split())
cnt=0

for i in range(math.gcd(a,b),0,-1):
    if a%i==0 and b%i==0:
        cnt+=1
    
    if cnt==k:
        print(i)
        break