def divisors(n):
    d=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
    d.sort()
    return d

a,b,k=map(int,input().split())
print(sorted(list(set(divisors(a))&set(divisors(b))))[::-1][k-1]) def divisors(n):
    d=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
    d.sort()
    return d divisors d=[] d [] for i in range(1,int(n**0.5)+1):
        if n%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
     i range(1,int(n**0.5)+1) range 1 int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 if n%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
     n%i==0 n%i n i 0 d.append(i) d.append d append i if i!=n//i:
                d.append(n//i)
     i!=n//i i n//i n i d.append(n//i) d.append d append n//i n i d.sort() d.sort d sort return d d n n a,b,k=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b k print(sorted(list(set(divisors(a))&set(divisors(b))))[::-1][k-1]) print sorted(list(set(divisors(a))&set(divisors(b))))[::-1][k-1] [::-1] (list(set(divisors(a))&set(divisors(b)))) sorted list(set(divisors(a))&set(divisors(b))) list set(divisors(a))&set(divisors(b)) set(divisors(a)) set divisors(a) divisors a set(divisors(b)) set divisors(b) divisors b ::-1 -1 k-1 k 1 a,b,k=map(int,input().split()) map(int,input().split()) a b,k=map(int,input().split()) map(int,input().split()) b def divisors(n):
    d=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
    d.sort()
    return d def divisors(n):
    d=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
    d.sort()
    return d divisors k=map(int,input().split()) map(int,input().split()) k
def divisors(n):
    d=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
    d.sort()
    return d

a,b,k=map(int,input().split())
print(sorted(list(set(divisors(a))&set(divisors(b))))[::-1][k-1])