import fractions as f 

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

g=f.gcd(a,b)

count=0

for s in range(g,0,-1):

    if g%s==0:

        count+=1

    if count==k:

        print(s)

        exit()
a,b,k=list(map(int,input().split()))

l=[]

for i in range(min(a,b),0,-1):

    if a%i==b%i==0:

        l.append(i)

print((l[k-1]))
import fractions as f

a, b, k = list(map(int, input().split()))
g = f.gcd(a, b)
count = 0
for s in range(g, 0, -1):
    if g % s == 0:
        count += 1
    if count == k:
        print(s)
        exit()

a, b, k = list(map(int, input().split()))
l = []
for i in range(min(a, b), 0, -1):
    if a % i == b % i == 0:
        l.append(i)
print((l[k - 1]))

-import fractions as f - -g = f.gcd(a, b) -count = 0 -for s in range(g, 0, -1): -    if g % s == 0: -        count += 1 -    if count == k: -        print(s) -        exit() +l = [] +for i in range(min(a, b), 0, -1): +    if a % i == b % i == 0: +        l.append(i) +print((l[k - 1]))