def readinput():
    a,b,k=list(map(int,input().split()))
    return a,b,k

def main(a,b,k):
    ans=0
    count=0
    for i in range(min(a,b),0,-1):
        if a%i==0 and b%i==0:
            count+=1
            if count==k:
                return i


if __name__=='__main__':
    a,b,k=readinput()
    ans=main(a,b,k)
    print(ans) def readinput():
    a,b,k=list(map(int,input().split()))
    return a,b,k readinput 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 return a,b,k return a,b,k a b k def main(a,b,k):
    ans=0
    count=0
    for i in range(min(a,b),0,-1):
        if a%i==0 and b%i==0:
            count+=1
            if count==k:
                return i main ans=0 ans 0 count=0 count 0 for i in range(min(a,b),0,-1):
        if a%i==0 and b%i==0:
            count+=1
            if count==k:
                return i i range(min(a,b),0,-1) range min(a,b) min a b 0 -1 if a%i==0 and b%i==0:
            count+=1
            if count==k:
                return i a%i==0 and b%i==0 a%i==0 a%i a i 0 b%i==0 b%i b i 0 count+=1 count 1 if count==k:
                return i count==k count k return i i a a b b k k if __name__=='__main__':
    a,b,k=readinput()
    ans=main(a,b,k)
    print(ans) __name__=='__main__' __name__ '__main__' a,b,k=readinput() a readinput() readinput b k ans=main(a,b,k) ans main(a,b,k) main a b k print(ans) print ans def main(a,b,k):
    ans=0
    count=0
    for i in range(min(a,b),0,-1):
        if a%i==0 and b%i==0:
            count+=1
            if count==k:
                return i def main(a,b,k):
    ans=0
    count=0
    for i in range(min(a,b),0,-1):
        if a%i==0 and b%i==0:
            count+=1
            if count==k:
                return i main def readinput():
    a,b,k=list(map(int,input().split()))
    return a,b,k def readinput():
    a,b,k=list(map(int,input().split()))
    return a,b,k readinput k=readinput() readinput() k a,b,k=readinput() readinput() a b,k=readinput() readinput() b ans=main(a,b,k) main(a,b,k) ans
def readinput():
    a,b,k=list(map(int,input().split()))
    return a,b,k

def main(a,b,k):
    ans=0
    count=0
    for i in range(min(a,b),0,-1):
        if a%i==0 and b%i==0:
            count+=1
            if count==k:
                return i


if __name__=='__main__':
    a,b,k=readinput()
    ans=main(a,b,k)
    print(ans)
